Last active
May 29, 2019 19:35
-
-
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
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
<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