Created
September 10, 2014 00:23
-
-
Save stevewithington/373fe25a56ee9d21be9b to your computer and use it in GitHub Desktop.
Mura CMS: How to get the primary associated image metadata such as AltText, Caption, Credits, etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset itKids = $.content().getKidsIterator() /> | |
<cfif itKids.hasNext()> | |
<ul> | |
<cfloop condition="itKids.hasNext()"> | |
<li> | |
<cfscript> | |
item = itKids.next(); | |
fileid = item.getValue('fileid'); | |
if ( item.hasImage() ) { | |
fileMeta = $.getBean('fileMetaData').loadBy(fileid=item.getFileID()); | |
WriteDump(var=fileMeta.getAllValues()); | |
} else { | |
WriteOutput('This item, (#item.getTitle()#), does not have an associated image.'); | |
} | |
</cfscript> | |
</li> | |
</cfloop> | |
</ul> | |
</cfif> |
@AlHolden , did you ever get anywhere with it?
<cfscript>
fileid = $.content().getValue('fileid');
if ( $.content().hasImage() ) {
fileMeta = $.getBean('fileMetaData').loadBy(fileid=$.content().getFileID());
WriteDump(var=fileMeta.getAllValues());
} else {
WriteOutput('This item, (#$.content().getTitle()#), does not have an associated image.');
}
</cfscript>
Thing is, this was written for an iterator, and not an individual content item, the above is tweaked, though untested, to operate on the current content item.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would one employ this snippet?
As a component, or embedded via [mura]$.dspInclude... it doesn't work. hasNext() returns false, even when the page has an associated image with credits.
Do we actually need to modify a display_object file in order to get image credits?