Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt November 11, 2024
MeekelTM Posted August 9, 2015 Posted August 9, 2015 I'm trying to allow our writers to upload MP4 files and image files as part of a featured image field we use. Is there a way to use the {{if}} statement as per below however changing the first line to check if the value ends with a specific file format? Is it possible to use raw PHP at all?I was referring to https://community.invisionpower.com/4docs/advanced-usage/development/template-logic-r73/ to see if I could come up with something however kept getting an error. {{if $value}} <img src="{$value}" width="335px" /> {{elseif}} <video width="335" height="188" autoplay loop> <source src="{$value}" type="video/mp4"> Your browser does not support the video tag. </video> {{endif}}
MeekelTM Posted August 9, 2015 Author Posted August 9, 2015 Got it working in the end. Slightly easier than I thought:{{if (substr($value, -4) == '.mp4') }} <video width="335" height="188" autoplay loop> <source src="{$value}" type="video/mp4"> Your browser does not support the video tag. </video> {{else}} <img src="{$value}" width="335px" /> {{endif}}
Recommended Posts
Archived
This topic is now archived and is closed to further replies.