Copied to clipboard

Flag this post as spam?

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


  • Jason Denousse 24 posts 93 karma points
    Mar 30, 2020 @ 14:47
    Jason Denousse
    0

    v7 code not working in v8 for media picker

    In v7 i used this code so that the image chosen from media picker would show

     <div>
                        @{
        var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("advert1");
        if (typedMediaPickerSingle != null)
        {
            <img src="@typedMediaPickerSingle.Url" />
        }
    }
                    </div>
    

    However it doesn't work in v8. Thoughts?

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Mar 30, 2020 @ 19:55
    Marc Goodson
    0

    Hi Jason

    Does...

     <div>
                        @{
        var typedMediaPickerSingle = Model.Value<IPublishedContent>("advert1");
        if (typedMediaPickerSingle != null)
        {
            <img src="@typedMediaPickerSingle.Url" />
        }
    }
                    </div>
    

    The syntax for writing out properties in this fashion has changed subtely in V8, GetPropertyValue has become just Value, and Model.Content has been replaced by just Model.

    regards

    marc

Please Sign in or register to post replies

Write your reply to:

Draft