Copied to clipboard

Flag this post as spam?

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


  • Owain Williams 479 posts 1410 karma points MVP 6x c-trib
    Sep 22, 2016 @ 09:27
    Owain Williams
    0

    Pull cropped image to main homepage

    Hi! I've been playing around with some bits within Articulate but this one is puzzling me. I've created a cropped image within my blog post with the built in Image Cropper provided by Umbraco. I just can't seem to be able to pull that image on to my front page though.

    Here is my code:

        <div class="image">
    
     @if (blogNode.GetPropertyValue("featuredImage") != null)
                        {
    
                            var imageId = blogNode.GetPropertyValue("featuredImage");
                            var altText = blogNode.GetPropertyValue("alternativeImageText");
    
    
    
                            <a href="@blogNode.Url">    <img src="@Url.GetCropUrl(Model.Content, "cropper", "thumbnail")" /></a>
                        }
                        else
                        {
                            <a href="@blogNode.Url">     <img src="@Umbraco.Media(1925).Url" alt="New blog post" class="img-thumbnail" /></a>
                        }
    
    
    
    
      </div>
    

    I've tried a couple of ways but nothing. Any help would be great.

  • Dennis Adolfi 1082 posts 6445 karma points MVP 5x c-trib
    Sep 22, 2016 @ 09:55
    Dennis Adolfi
    100

    Hi Owain.

    From what i understand, your blogNode has a property for the image called "featuredImage", and its a datatype is called "cropper" and you want the specific crop called "thumbnail"? Is this correct?

    In that case, try:

    @blogNode.GetCropUrl("featuredImage", "thumbnail");

  • Owain Williams 479 posts 1410 karma points MVP 6x c-trib
    Sep 22, 2016 @ 10:58
    Owain Williams
    1

    Thanks Dennis, that put me on the right track.

    I made a couple of changes to the datatype on the blog and it now works.

  • Dennis Adolfi 1082 posts 6445 karma points MVP 5x c-trib
    Sep 22, 2016 @ 13:06
    Dennis Adolfi
    0

    Awesome, glad i could help Owain!

    Have a great day!!!

Please Sign in or register to post replies

Write your reply to:

Draft