Copied to clipboard

Flag this post as spam?

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

  • Ault Nathanielsz 30 posts 124 karma points
    Nov 23, 2018 @ 12:30
    Ault Nathanielsz

    I obviously lack a basic bit of understanding of this method...

    This works:

    <img src="@Url.GetCropUrl(Model.Content.WtImageBackground, "L")" />

    (Where WtImageBackground is the alias of the image and "L" is the crop name.

    However, when I call the children of the current page, this does not work

    var wtChildren = Model.Content.Children();
                                        foreach (var wtChild in wtChildren)
                                            <img src="@Url.GetCropUrl(wtChild.GetPropertyValue("WtImageBackground"), "L")" />

    However, if I only call wtChild.GetPropertyValue("WtImageBackground") I get the numeric reference of the image, much the same as I do with Model.Content.WtImageBackground.

    Any thoughts on getting this working or any links to a resource that might give me a thorough understanding of Url.GetCropUrl would be appreciated.

  • Marc Goodson 887 posts 5808 karma points MVP 4x c-trib
    Nov 23, 2018 @ 13:49
    Marc Goodson

    Hi Ault

    What if you have?

       <img src="@Url.GetCropUrl(wtChild.GetPropertyValue<IPublishedContent>("WtImageBackground"), "L")" />

    Essentially GetPropertyValue without the <type> , will return an object, which then GetCropUrl won't be expecting...

    but think if PropertyValueConverters are enabled, and you specifically say the type is IPublishedContent of your media item, then that might make it work?



  • Ault Nathanielsz 30 posts 124 karma points
    Nov 23, 2018 @ 15:57
    Ault Nathanielsz

    Thanks Marc, that did the trick.

    I keep thinking that I should be able to do this without IPublishedContent... but I'll let it be for the time being.

Please Sign in or register to post replies

Write your reply to: