Reliable method to display/hide web client label image

I have a form with a table view on it. The underlying records have a text field containing a path to a PDF file. This file may or may not exist. If it does exist, I want to display a little PDF icon for that record. If it doesn’t exist, I want a blank space.

In 6.0.x this used to work in the onRender() event of the button/label:

/** @type {JSRecord<{attachmentpath:String}>} */
var eventRec = JSRecord;
var currAttachpath = '';
	
eventRec = event.getRecord();
currAttachpath = eventRec.attachmentpath;
	
/** @type {JSLabel} */
var thisButton = event.getRenderable();
	
// -- Return icon depending on whether attachment file actually exists.
var attachmentFile = plugins.file.convertToJSFile(currAttachpath);
if (attachmentFile.exists()) 
{
    imageURL = 'media:///pdficon_small.gif';
}
else
    imageURL = 'media:///attachment_transparent.gif';
		
thisButton.imageURL = imageURL;

However that stopped working in 7.x, as the imageURL property is not available via getRenderable().

I have changed it to this (common code omitted):

thisButton.visible = (attachmentFile.exists()) ? true : false;

… however that is giving inconsistent results. Is there any reliable way to do this in web client?

OK seems I managed to do it by using a HTML Area instead. This has a calculation that returns a HTML string as its dataprovider, like this:

function haspdf()
{
	var ret = '<html><img src="media:///attachment_transparent.gif"></html>'
	var currAttachpath = attachmentpath;
	
	if (currAttachpath)
	{
		var attachmentFile = plugins.file.convertToJSFile(currAttachpath);
		if (attachmentFile.exists())		
			ret = '<html><img src="media:///pdficon_small.gif"></html>'
	}
	
	return ret;
}