We have a website with a reasonably big media library. We have just added some defined crops to the Image Cropper datatype - however, none of the existing images have any of the defined crops until the image is saved again.
We can't go through the entire media library to save every image, to create the crops - so is there a simpler way?
Do you NEED to save each image? I would expect GetCropUrl() to work even if the crop hadn't been selected based on the focus (blue blob) position of the image. That will be dead centre by default.
If it is as you say then you should be able to write some code using the ContentService that grabs all media and saves it back with the crop.
This code grabs the crop data for an IPublishedContent(mediaChild).
@using Newtonsoft.Json
@using Umbraco.Web.Models
var imageCrops = JsonConvert.DeserializeObject<ImageCropDataSet>(mediaChild.GetPropertyValue<string>("umbracoFile"));
It shouldn't be too hard to convert this to IContent use, change ImageCrops and save it back to the IContent.
Create Crops for existing images
We have a website with a reasonably big media library. We have just added some defined crops to the Image Cropper datatype - however, none of the existing images have any of the defined crops until the image is saved again.
We can't go through the entire media library to save every image, to create the crops - so is there a simpler way?
Do you NEED to save each image? I would expect
GetCropUrl()
to work even if the crop hadn't been selected based on the focus (blue blob) position of the image. That will be dead centre by default.If it is as you say then you should be able to write some code using the ContentService that grabs all media and saves it back with the crop.
This code grabs the crop data for an
IPublishedContent
(mediaChild
).It shouldn't be too hard to convert this to
IContent
use, changeImageCrops
and save it back to theIContent
.is working on a reply...
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.