Copied to clipboard

Flag this post as spam?

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


  • Shakib 32 posts 134 karma points
    Jun 12, 2017 @ 10:42
    Shakib
    0

    Problem Retrieving Media Url in Umbraco 7.6.3

    Hi
    i just updated my umbraco to 7.6.3, but i encounter with this error in my views that i use .Url property like below:

    @Umbraco.Media(CurrentPage.photoMedium).Url
    

    how can i retrive media url in this new version ??

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 12, 2017 @ 10:46
    Alex Skrypnyk
    1

    Hi Shakib

    Since version 7.6 Umbraco has Property Value Converters in the core, so you can access your Media like:

            var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("photoMedium");
            if (typedMediaPickerSingle != null)
            {
                <p>@typedMediaPickerSingle.Url</p>
            }
    

    Also, you can disable this functionality in umbracoSettings.config EnablePropertyValueConverters set to false.

    Hope it will help you.

    Thanks,

    Alex

  • Shakib 32 posts 134 karma points
    Jun 12, 2017 @ 13:02
    Shakib
    0

    this code returns me null, but in the backoffice i can see that one image selected for "photoMedium" property and every thing is ok.
    i dont know where is the problem.

  • Shakib 32 posts 134 karma points
    Jun 12, 2017 @ 13:20
    Shakib
    0

    when i disable Property Value Converters functionality every thing looks good.
    but i guess something is wrong with this Property Value Converters.
    another question i have is that why mediapicker is obsolete?what is the replace for that ??

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 12, 2017 @ 13:33
    Alex Skrypnyk
    1

    Hi Shakib

    mediapicker is obsolete

    mediapicker2 is replacement for old mediapicker

    You can still use mediapicker with version 7.6, but in future it will be totally replaced by mediapicker2

    The difference between mediapicker and mediapicker2, how it stores the media id. First one works with 4 digits id, second one works with udi ids, it's more reliable and flexible way.

    Thanks,

    Alex

  • Paul Wright (suedeapple) 277 posts 704 karma points
    Jun 12, 2017 @ 14:18
    Paul Wright (suedeapple)
    2
    @CurrentPage
    

    Is "dead" too :-), so keep things as @Model......

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Jun 12, 2017 @ 16:02
    Paul Seal
    1

    See my updated blog post which at the top shows how to get it for 7.6x and after that the original for 7.5x and below.

    http://www.codeshare.co.uk/blog/how-to-get-the-file-path-of-a-media-item-in-umbraco/

    Kind regards

    Paul

  • Shakib 32 posts 134 karma points
    Jun 13, 2017 @ 06:12
    Shakib
    1

    thanks every one for helping me.
    it was really helpful.

Please Sign in or register to post replies

Write your reply to:

Draft