Copied to clipboard

Flag this post as spam?

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


  • Paul Griffiths 370 posts 1021 karma points
    Aug 26, 2016 @ 18:56
    Paul Griffiths
    0

    Null object cannot be converted to a value type.

    Hi All,

    All of a sudden i am receiving the following error when trying to get a crop from my image cropper data type.

    My code is as follows, is this the correct way to call the crop? My property is called image and my prop alias is latestNewsCrop.

        @foreach (var newsItem in Model.Content.Children.OrderBy("CreateDate desc"))
    
    {
                                <a href="@newsItem.Url" title="@newsItem.Name">
                                    <img src="@(newsItem.HasValue("image") ? newsItem.GetCropUrl("image", "latestNewsCrop") : placeHolderImage)" class="img-responsive" alt="" title="">
                                </a>
    
    }
    

    The error i get is as follows

    enter image description here

    Anyone help?

    Thanks Paul

  • Paul Griffiths 370 posts 1021 karma points
    Aug 26, 2016 @ 19:23
    Paul Griffiths
    0

    Maybe its related to this? http://issues.umbraco.org/issue/U4-8769

    {
      "focalPoint": {
        "left": null,
        "top": null
      },
      "src": "/media/1021/img_5512.jpg",
      "crops": [
        {
          "alias": "latestNewsCrop",
          "width": 800,
          "height": 300,
          "coordinates": {
            "x1": 5.0527483431829317E-16,
            "y1": 0.28306712962962971,
            "x2": 0,
            "y2": 0.15443287037037051
          }
        }
      ]
    }
    

    Anyone had this?

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 26, 2016 @ 21:28
    Dan Diplo
    0

    I think it is related to that. I'd upvote the issue if you can.

  • Paul Griffiths 370 posts 1021 karma points
    Aug 27, 2016 @ 07:04
    Paul Griffiths
    0

    Hi,

    Thanks for getting back, as strange as this may sound I've just moved the blue focal point on the image that was uploaded and then re cropped the image using latestNewsCrop, republished and it now renders!

    Really don't know what's going on - seems quite buggy

    Paul

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Aug 27, 2016 @ 09:51
    Dan Diplo
    0

    No, doesn't sound strange, as I've encountered the same. Sometimes the focal point "shoots off" which results in a null position being set. This is turn causes the property converter (that takes the JSON that is stored in Umbraco and converts it back to an ImageCropDataSet object) to throw the exception you saw.

    I'd just urge people to vote for the issue at http://issues.umbraco.org/issue/U4-8769 so the core team see it as important.

Please Sign in or register to post replies

Write your reply to:

Draft