Hi all, not sure if this is a Umbraco 7 query or a Razor query but I need the Media Type of a certain media from the Multiple Media Picker. It would need to be specific, ie a PDF, a DOC file. Not just File, Folder, Image. Is this possible?
If not is there a way, to get the file extension from the URL using Razor?
My code so far:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@if (Model.Content.HasValue("resouces"))
{
var docList = Model.Content.GetPropertyValue<string>("resouces").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var docCollection = Umbraco.TypedMedia(docList).Where(x => x != null);
foreach (var docItem in docCollection)
{
//Need if statement for media type
<img src="@docItem.Url" />
}
Get Media Type
Hi all, not sure if this is a Umbraco 7 query or a Razor query but I need the Media Type of a certain media from the Multiple Media Picker. It would need to be specific, ie a PDF, a DOC file. Not just File, Folder, Image. Is this possible?
If not is there a way, to get the file extension from the URL using Razor?
My code so far:
Any help would be great, thank in advance.
Hi Jason,
One way you can get the file extension, of a media item is by using this:
I hope this can help you further.
/Dennis
Excellent Dennis, exactly what I was after.
Cheers
Jason
is working on a reply...