Needs review
Project:
Manual Crop
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Feb 2022 at 22:40 UTC
Updated:
10 Jun 2022 at 11:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dsnopekThe attached patch fixes the problem in my testing.
The change in 7.88 prevents elements of type 'value' from getting processed. However, in this case, this isn't really even a 'value' element, its a parent of a 'hidden' element, which is what is ultimately processed and contains the crop information. So, I think it's safe to remove the '#type' entirely, although, maybe it could be made a 'container' instead?
Assuming this works in testing by others, I'll get it integrated into Panopoly for the next release.
Comment #3
cboyden commentedI've tested this on a Panopoly child distribution and it works to fix the issue without any side effects that I can see.
Comment #4
stephen-cox commentedPatch #2 works for me. After upgrading Manual Crop to 1.7 and applying the patch, image cropping works again with the latest Drupal 7.
Comment #5
stephen-cox commentedComment #6
curlymike commentedHi, everyone!
I'm using manualcrop on a custom form (aside FAPI image fields) and have been affected by this issue.
Removing element #type does not sit well with me, so I looked deeper into the code and I do not understand why $element['manualcrop']['file_' . $file->fid]['#default_value'] (element #type value) array created in manualcrop_croptool_process() (7.x-1.7 manualcrop.helpers.inc line 218,247) overlaps it's child elements $element['manualcrop_selections'][$style_name] (#type hidden) added by _manualcrop_add_croptool() (line 440). It even picks values for hidden elements from parent's values array! Those values going to $form_state['values'] definitely overlap and value of the #type => value parent overwrites values of it's #type => hidden children it seems.
Here is the patch that solves the issue for me, it doesn't seem to break FAPI usage or anything else (for me), but it would be great if someone who's familiar with manualcrop inner workings looked into it.
For now I'm using a workaround and set $element['manualcrop']['#default_value'] = array() for all added elements after calling manualcrop_croptool_process(), this way I don't need to patch manualcrop.
Comment #7
curlymike commented