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).
Comments
Comment #1
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 commentedWell, that was even easier than expected.
Patch changes a few classes.
Comment #3
David_Rothstein 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 commentedAdded a small fix to prevent duplicate images from appearing in the widget sometimes.
Comment #5
rudiedirkx commentedI don't do or know Media, so I can't test it...
Comment #6
fabianx 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 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 commentedRe-rolled and added missing comment mentioned in #10 by @Fabianx