Copied to clipboard

Flag this post as spam?

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


  • Snow lizard 36 posts 106 karma points
    Jan 23, 2015 @ 19:15
    Snow lizard
    0

    Use GetCropUrl in new itesm

    Hi, 

    What i want to do is use a thumbnail image for my new stories on my homepage. It works when the data type alias is on the page i.e

    <img src='@CurrentPage.GetCropUrl("solution1Image", "SolutionsImageCropper")' />

    However i can't work out how to use the GetCropUrl when it's included on this razor macro which displays2 news stories. I want to get the crop url on this @page.newsThumbnailImage2 in the razor code below.

    Can anyone help. Thanks

    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{

    var newsItems = Model.NodeById(1075);

    var sortedItems = newsItems.Children.OrderBy("createDate descending").Take(2);

    foreach(var page in sortedItems.Where("visible"))

    {

    <p>@page.newsThumbnailImage2</p>

    }

    }

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 23, 2015 @ 19:19
    Jan Skovgaard
    0

    Hi Alan

    I think that it should work if you write this

    @inherits umbraco.MacroEngines.DynamicNodeContext
    
     @{
    
         var newsItems = Model.NodeById(1075);
    
         var sortedItems = newsItems.Children.OrderBy("createDate descending").Take(2);
    
         foreach(var page in sortedItems.Where("visible"))
    
         {
    
         <img src="@page.GetCropUrl('newsThumbnailImage2', 'SolutionsImageCropper')" />     
    
         }
    
    }
    

    Does this work?

    /Jan

  • Snow lizard 36 posts 106 karma points
    Jan 23, 2015 @ 19:35
    Snow lizard
    0

    Thanks Jan, it comes back with an error message though:

    Too many characters in character literal

     

  • Snow lizard 36 posts 106 karma points
    Jan 23, 2015 @ 19:36
    Snow lizard
    0

    Thanks Jan, nothing coming back though

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jan 23, 2015 @ 19:56
    Jeavon Leopold
    0

    Hi Alan,

    You cannot use GetCropUrl in a legacy macro Razor script (DynamicNode).

    You need to use it in a View, Partial View or a Partial View Macro.

    Jeavon

  • 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