Copied to clipboard

Flag this post as spam?

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


  • siko 24 posts 77 karma points
    Jul 17, 2017 @ 13:08
    siko
    0

    .GetCropUrl works, and then it doesnt

    Hello,

    I must be missing something obvious, but GetCropUrl works:

    @{ 
        var imageNode = Model.Content.GetPropertyValue<IPublishedContent>("slideImage");
        string imgUrl = imageNode.GetCropUrl("blog post");
    }
    <img src="@imgUrl" alt="">
    <a class="overlay-link popup-img" href="@imgUrl"><i class="fa fa-search-plus"></i></a>
    @Model.Content.GetPropertyValue("slideContent")
    

    And then in another view, it doesn't

                @foreach (var solution in CurrentPage.Children())
                {
                    var imageNode = solution.GetPropertyValue<IPublishedContent>("bannerImage");
                    string imgUrl = imageNode.GetCropUrl("blog post");
                }
    

    I don't 'get' it... maybe someone can shed some light?

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Jul 17, 2017 @ 13:10
    Alex Skrypnyk
    100

    Hi Siko

    Try this code:

    @foreach (var solution in Model.Content.Children())
    {
        var imageNode = solution.GetPropertyValue<IPublishedContent>("bannerImage");
        string imgUrl = imageNode.GetCropUrl("blog post");
    }
    

    The problem in your code is that "CurrentPage" is dynamic type in this line:

    @foreach (var solution in CurrentPage.Children())
    

    Thanks,

    Alex

  • siko 24 posts 77 karma points
    Jul 17, 2017 @ 18:13
    siko
    0

    Thanks. I found it and yes, you are right!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies