Copied to clipboard

Flag this post as spam?

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


  • Jeroen Oostwouder 67 posts 163 karma points
    Jun 05, 2015 @ 09:14
    Jeroen Oostwouder
    0

    Getting the cropped image doesn't work

    I want to display a cropped image, but it doesn't work.

    This is what I do:

    var node = new umbraco.MacroEngines.DynamicNode(
    ConfigurationManager.AppSettings["nodeID_News"].AsInt()
    );
    
    foreach (dynamic newsNode in node.Children()) {
        if (newsNode.HasValue("image")) {
            var imageUrl = newsNode.GetCropUrl("image", "newsOverview");
            <img src="@imageUrl">
        }
    }
    

    newsNode.image has a value, because I see the <img> tag getting rendered. And when I put a watch on newsNode.image, it shows me the following:

    {
      "focalPoint": {
        "left": 0.5,
        "top": 0.5
      },
      "src": "/media/1007/nieuws.jpg",
      "crops": [
        {
          "alias": "newsOverview",
          "width": 307,
          "height": 261
        }
      ]
    }
    

    So there is a crop and a media item available. But still, GetCropUrl returns a {}

    What am I doing wrong here?

  • 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