Copied to clipboard

Flag this post as spam?

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


  • Ian Smedley 97 posts 192 karma points
    Jun 06, 2013 @ 11:20
    Ian Smedley
    1

    BUG: NullException using TypedCrops with DAMP.PropertyEditorValueConverter.Model

    Hello,

    I've just had 'one of those' bugs which took a seemingly long time to track down exactly what was causing it - but now it's all clear - so I thought I'd post up the details so that a fix could maybe be added to the source.

    If you have a media item - with the Image cropper - and you have, for instance two properties on this media item:

    • Image   - (File Upload)
    • Crop     - (Image Cropper)
    In Razor when you use the DAMP_Item model - and you try to access TypedCrops (TypedCrops.Count) for instance - you will get a null reference exception!
    I evenutally took a look at the source and found my property name of "crop" to be at fault - this line of code in TypedCrops will pickup the empty '<crop>' tag - which doesn't contain any attributes - and so the unhandled exception occurs:
    _typedCrops.Add(item.Attributes["name"].Value.ToLower(), item.Attributes["url"].Value);
    
    My solution was to change the Umbraco property name to something other than crop - in essence it's a reserved word -  a better solution would be handle gracefuly the occurance of <crop> tags which don't contain actual crop attributes..
    Here's a snippet of the original xml that caused the troubles:
      <image>/media/3084/img_8149.jpg</image>
      <crop>
        <crops date="2013-06-06T09:24:21">
          <crop name="Big" x="103" y="0" x2="4273" y2="2848" url="/media/3084/img_8149_Big.jpg" />
          <crop name="Normal" x="3" y="349" x2="4273" y2="2202" url="/media/3084/img_8149_Normal.jpg" />
        </crops>
      </crop>
    Hope this helps someone out!
    Kind Regards,
    Ian

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jun 18, 2013 @ 12:12
    Jeroen Breuer
    0

    I'll see if I can fix this for the next version. For now just don't name the ImageCropper on your Media Type 'crop'.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft