Every Media item uploaded has a special property with alias called 'umbracoExtension'
So you should be able to read that from your hero property (if that is a picked media item), I usually do a similar thing to display an appropriate icon next to the file... but you could just change the markup depending on the type:
eg
var fileExtension = Model.Hero.Value<string>("umbracoExtension");
string iconClass = "fa-file-download";
switch (fileExtension) {
case "pdf":
iconClass = "fa-file-pdf";
break;
case "ppt":
case "pptx":
iconClass = "fa-file-powerpoint";
break;
case "xls":
case "xlsx":
iconClass = "fa-file-excel";
break;
case "doc":
case "docx":
iconClass = "fa-file-word";
break;
case "mp4":
iconClass = "fa-file-video";
break;
case "jpg":
case "jpeg":
case "png":
case "gif":
iconClass = "fa-file-image";
break;
}
Can I check what media is about to be rendered using a Media Picker?
Is there a way I can find out what sort of file is in the Media Picker and render it out accordingly.
For images I would use
Say a video (.mp4) was uploaded, however, I would need to format it for a video.
Can I do a check based on the extension, perhaps?
If it's an image do this, for a video, this?
Thanks in advance
Hi David
Every Media item uploaded has a special property with alias called 'umbracoExtension'
So you should be able to read that from your hero property (if that is a picked media item), I usually do a similar thing to display an appropriate icon next to the file... but you could just change the markup depending on the type:
eg
if that helps give you a steer?
regards
Marc
Can't thank you enough Marc :-)
is working on a reply...