U4-7695 - Media items are not updated when a new crop is added to Image Cropper

Created by Rune Strand 11 Jan 2016, 14:18:15 Updated by Stephan 10 Feb 2016, 13:40:47

Relates to: U4-7891

What did you do? I uploaded some images to the Media Library and then added a new crop to the Image Cropper data type (which is the standard upload for 7.4)

What did you expect to happen? I expected to be able to use a media picker and then render the image using the crop:

var image = Umbraco.Media(item.image);
<img src="@image.GetCropUrl("promoHome")">

What actually happened?

An empty string is returned because the new crop definition has not been saved on the media item. If I go to the Media Library and save the image the crop information is updated and the image is rendered as it should be.


Shannon Deminick 26 Jan 2016, 14:52:42

This is being marked as a breaking changed because:

  • To facilitate this fix, a PropertyValueConverter is required for the ImageCropper which now makes the default value a JObject instead of a string
  • This will not break any existing usages of GetCropUrl because that uses this to get the value: mediaItem.GetPropertyValue<string> which just does a ToString() on JObject which results in the json string anyways
  • This means people will not need to deserialize the cropper raw string value to JObject to use it

If developers are using either:

     //this will now cause an exception since it's returning a JObject
    //this will return null because it's returning a JObject
     mediaItem.GetPropertyValue("image") as string

They will need to update their usages.

Shannon Deminick 26 Jan 2016, 14:54:35

PR for review: https://github.com/umbraco/Umbraco-CMS/pull/1056

Claus Jensen 28 Jan 2016, 17:30:56

Code looks good and confirmed its working.

Priority: Task - Pri 1

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: False

Fix Submitted:

Affected versions: 7.4.0

Due in version: 7.4.0

Sprint: Sprint 7

Story Points: