Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active April 28, 2020 15:26
Show Gist options
  • Save stevewithington/6272777 to your computer and use it in GitHub Desktop.
Save stevewithington/6272777 to your computer and use it in GitHub Desktop.
Mura CMS : Meta Image / Primary Associated Image Output
<!---
This is one way to generate a custom meta image based on the content item's primary associated image.
You could use this method in several other ways as well, such as inside a content iterator, etc.
If the fileid passed into this method is not a valid image, then it will return an empty string
--->
<cfif Len($.getURLForImage($.content('fileid')))>
<cfscript>
img = $.getURLForImage(
fileid = $.content('fileid') // could be _any_ fileid in Mura
,size = 'custom' // small, medium, large, custom, or any other pre-defined image size
,width = 300 // only needed if using size='custom'
,height = 100 // only needed if using size='custom'
,complete = false // set to true to include the entire URL, not just the absolute path (default)
,siteid = $.event('siteid') // could pull an image from another siteid, if desired
);
</cfscript>
<a href="#$.getURLForImage($.content('fileid'))#" title="#esapiEncode('html_attr', $.content('title'))#" rel="shadowbox[body]">
<img src="#img#" alt="#esapiEncode('html_attr', $.content('title'))#">
</a>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment