Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • LeszekP 27 posts 78 karma points
    Jun 15, 2015 @ 23:00
    LeszekP
    0

    MediaFile model and only 4 properties mapped

    Hi,

    I could not find how to get all MediaFiles properties mapped from Umbraco IPublishedContent Image.

    After mapping only: Id, DocTypeAlias Name, Url

    are set. How about size, extension, etc? Do I need to set it up to map manually?

    public static object MapImage<T>(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyName,
            bool isRecursive) where T : MediaFile, new()
        {
            var image = new T();
    
            var content = contentToMapFrom.GetPropertyValue<IPublishedContent>(propertyName, isRecursive);
            if (content != null)
            {
                mapper.Map(content, image);
            }
    
            return image;
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft