Accessing Extended Attribute Images in Mura CMS

December 01, 2016

(Because I always forget now to do this, I’m going to save it here for later reference.)

Sometimes I have an Extended Attribute that is an image. Maybe it’s named “EventImage”, for example.  If it were just the regular Associated Image for a Page, I could do this:

<img src=“#pageBean.getImageURL()#” />

…and that would work. But Extended Attributes are a little different.  The value “EventImage” won’t include any of the path to where that image in stored.  So you have to get the Extended Attribute in question, plus build a valid path to where it’s located, like so:

<cfset myEventsPageBean = $.getBean( "content" ).loadBy( title=“My Events Page”, siteID = $.event( "siteid" ) ) />    
<cfset myEventImage = $.createHREFForImage( fileId = myEventsPageBean.getEventImage() ) />
<img src=“#myEventImage#” />

There are probably 10 other ways to do this in Mura too.