Copied to clipboard

Flag this post as spam?

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


  • Mark Bro 15 posts 86 karma points
    Jul 25, 2014 @ 03:59
    Mark Bro
    0

    Passing node property values to GetCropUrl

    Hi,

    I have been able to successfully display a cropped image when hard coding the width and height values using the GetCropUrl method as shown below.

    <a id="@item.image" href="@featureImage.Url" title="@item.imageDescription">
                <img class="img-responsive" src="@featureImage.GetCropUrl(270, 161, furtherOptions:"&filter=comic")" alt="@item.Name"/>
            </a>
    

    However I would like to set this value in the node content and pass them in. For example I have create a property call imageWidth.

    <p>@item.imageWidth</p>
            <a id="@item.image" href="@featureImage.Url" title="@item.imageDescription">
                <img class="img-responsive" src="@featureImage.GetCropUrl(item.imageWidth, 161, furtherOptions:"&filter=comic")" alt="@item.Name"/>
            </a>
    

    Unfortunately I get the following error

    enter image description here

    In the paragraph tag it does show the property value I have set in the node at that point.

    Can anyone advise how to pass property values to the GetCropUrl.

    Thanks

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 25, 2014 @ 08:21
    Jeavon Leopold
    100

    Hi Mark,

    I'm guessing item is a dynamic object retrieved using CurrrentPage so we will need to cast it, e.g.

     <img class="img-responsive" src="@featureImage.GetCropUrl((int)item.imageWidth, 161, furtherOptions:"&filter=comic")" alt="@item.Name"/>
    

    Jeavon

  • Mark Bro 15 posts 86 karma points
    Jul 25, 2014 @ 21:18
    Mark Bro
    0

    Awesome thanks Jeavon, that did the trick!

    Appreciate all your help.

    Thanks,

    Mark

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jul 26, 2014 @ 10:17
    Jeavon Leopold
    0

    You're welcome. Could you please mark the above answer as the solution (clicking the green tick)?

    Thanks,

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft