Skip to content

Instantly share code, notes, and snippets.

@robertmorel-uk
Last active May 29, 2019 19:35
Show Gist options
  • Save robertmorel-uk/acdbe3caf301e61d8dbf8f7d7c56103f to your computer and use it in GitHub Desktop.
Save robertmorel-uk/acdbe3caf301e61d8dbf8f7d7c56103f to your computer and use it in GitHub Desktop.
Mura set custom alt tag on image with fallback title as alt
<cfscript>
<!---Set alt tag to be user defined or title as fallback--->
function altAltTags(getFileIdVal){
fileid = sub1.getValue('fileid');
if ( sub1.hasImage() ) {
fileMeta = getFileIdVal;
if ( Len(fileMeta.getAltText())){
writeoutput('alt="#fileMeta.getAltText()#"');
}
else{
writeoutput('alt="#sub1.getMenuTitle()#"');
}
}
}
</cfscript>
<cfscript>#altAltTags($.getBean('fileMetaData').loadBy(fileid=sub1.getFileID()))#</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment