Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
When you have a node with 2 image fields, with the same image (fid) but different required cropping styles, after cropping MC gets confused and marks all the images CROPPED, even though only 1 style was cropped. Saving then, results in avalidation error, because only 1 was cropped, but 2 were marked as "Crop (cropped)".
Reproduce
- Create node type with 2 required image fields, with FileField Sources, without any cropping
- Create 2 croppable image styles
- Create a node with both image fields filled with the same image (hence FileField Sources or alike)
- Update the node type fields to have different required cropping styles
- Edit the node, add cropping etc
Solution
In theory it's very simple: only update buttons/options that MATCH the just created cropping (fid + style), not just the cropped image (fid).
Comment | File | Size | Author |
---|---|---|---|
#13 | manualcrop-image-reuse--2508773-13.patch | 11.75 KB | douggreen |
#2 | manualcrop-2508773-1.patch | 2.11 KB | rudiedirkx |
Comments
Comment #1
rudiedirkx CreditAttribution: rudiedirkx commentedMight be related to #2043029: Cropping the same image in two different fields on the same node erases crop information but that mentions #1977606: Crop selection on same image in two nodes of two different node types (with difference in selectable styles) unsets selection as a fix, and that definitely does not fix this issue.
Comment #2
rudiedirkx CreditAttribution: rudiedirkx commentedWell, that was even easier than expected.
Patch changes a few classes.
Comment #3
David_Rothstein CreditAttribution: David_Rothstein at Tag1 Consulting commentedThe above didn't work for me when using the Media module's media library to get the same image to appear more than once on the same form. I had to make some additional changes in the attached:
This is not as big of a patch as it looks like - a lot of it is indentation changes due to a new foreach() loop.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein at Tag1 Consulting commentedAdded a small fix to prevent duplicate images from appearing in the widget sometimes.
Comment #5
rudiedirkx CreditAttribution: rudiedirkx commentedI don't do or know Media, so I can't test it...
Comment #6
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedRTBC - looks great to me.
Comment #7
Lennard WesterveldEdited: oops i broke it :) ignore my patch
Comment #8
Lennard WesterveldComment #9
Lennard WesterveldAdded new patch this one is working with the latest dev version
Comment #10
Fabianx CreditAttribution: Fabianx at Tag1 Consulting commentedWe lost a comment here compared to David's patch.
Comment #11
dqdCan someone confirm that the module has supported this ...
... firmly? Otherwise we should rather tag this a feature request instead of a bug? Because this can bring up a module version discussion, depending on if this will have surprising impact on already installed modules and sites.
Comment #12
Lennard Westerveld@Diqidoq nope this isn't a feature right now, so it needs to be a new one.
See manualcrop.helpers.inc
'id' => array('manualcrop-' . $crop_type . '-' . $fid),
'id' => 'manualcrop-area-' . $fid . '-' . $style_name,
And
manualcrop.js
ManualCrop.output = $('#manualcrop-area-' + fid + '-' + styleName);
Its right now not mode for it because of the html ids.
Comment #13
douggreen CreditAttribution: douggreen as a volunteer commentedRe-rolled and added missing comment mentioned in #10 by @Fabianx