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 87 posts 407 karma points c-trib
    Nov 23, 2018 @ 12:30
    Ault Nathanielsz
    0

    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 2148 posts 14352 karma points MVP 8x c-trib
    Nov 23, 2018 @ 13:49
    Marc Goodson
    100

    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?

    regards

    Marc

  • Ault Nathanielsz 87 posts 407 karma points c-trib
    Nov 23, 2018 @ 15:57
    Ault Nathanielsz
    0

    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:

Draft