Onlinebase

Mura CMS: Getting images

For a while I thought I had grasped the concept of getting an image of custom size in Mura CMS. But then I uploaded a couple of pictures of different sizes to a few categories and my Dashboard page was all over the place...

I was using this call:

#$.getUrlForImage(fileid=queryname.myId,size='Custom',height='dashboard',width='dashboard')#

to get the images, thinking my custom image size was looked after by Mura like an extended attribute or that the 'Custom' flag in the function call would be getting my 'dashboard' image sizes from my Mura settings. But alas - delving into the Mura function library I discovered that the getUrlForImage function cannot cope with custom image sizes - at least not as I thought it would do. It can however cope with custom image sizes if the witdh and height are numeric. But that would be silly in this case, as I had just specified a custom image size site-wide (i.e. 'dashboard'). I wanted Mura to give me 'filename_dashboard.fileextension'. So I dug a bit deeper into the Mura dungeons and came out with an epiphany: why not try and use the content bean getImageUrl function:

#$.getBean('content').loadBy(contentID='#queryname.myId#').getImageUrl(size='dashboard')#

And lo and behold there it was - my custom image size!

Geplaatst op 15 september 2014 om 18:28 u.

Alles in 'Ontwikkeling'

10 bericht(en)