Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How do I get the media alias in Umbraco 7?
And where can I see all the names of the properties?
How are you currently trying to fetch them? Using Razor or XSLT? Should be the same as you would do in earlier versions of Umbraco.
Are you using the new image cropper? If so then make sure to read the documentation here http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Image-Cropper
I've created a Media Type called Link, and in razor I would like to check what type I´m dealing with.
Is there a way to get Media by Type?
Actually there is a way, you can use MediaService as below to get a list of media files by Type.
you need to pass media type id, as an example I've passed 123.
var listOfMediaFilesByType = Services.MediaService.GetMediaOfMediaType(123)
I hope that helps.
You can also get the media type using the media type service if you dont know the id or dont want to hard code it:
var mType = UmbracoContext.Application.Services.ContentTypeService.GetMediaType("alias");
//check for null etc..
var media = UmbracoContext.Application.Services.MediaService.GetMediaOfMediaType(mType.Id);
foreach (var m in media)
//each media item
I think your code has gone wrong a little bit MemberTypeService ? Why Member?
Doh! I misread MemberType as MediaType. You need to use the ContentTypeService,
I have updated the post. :)
Sorry for the confusion.
thanks for your great help!
I've tried your code and it works, just not the way I wanted.
it's from the wrong side, I would like to take an item and see what type it was.
so I found out If I wrote this @item.ContentType what I get is Umbraco.Core.Models.PublishedContent.PublishedContentType
Umbraco.Core.Models.PublishedContent.PublishedContentType h = image.ContentType;
found it on this page our.umbraco.org/.../media
But thanks for the help, I really appreciate it!
Thanks Johan, for posting your solution. This worked for me and helped me a lot.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted