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.
Currently it seems D8 lacks the possibility to require croppings like in D7? Or am I mistaken?
The possibility to make some croppings required so user can not save node until those croppings are properly set.
This could be solved with the auto crop feature I've read about : https://www.drupal.org/node/2865396
Comment | File | Size | Author |
---|---|---|---|
#42 | interdiff-2871137-42.txt | 655 bytes | woprrr |
#42 | required_croppings-2871137-42.patch | 26.43 KB | woprrr |
#41 | interdiff-2871137-41.txt | 1.6 KB | woprrr |
#41 | required_croppings-2871137-41.patch | 26.44 KB | woprrr |
#35 | interdiff-2871137-35.txt | 3.05 KB | woprrr |
Comments
Comment #2
smanhoff CreditAttribution: smanhoff commentedComment #3
smanhoff CreditAttribution: smanhoff commentedComment #4
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHi @Sander Hofman
It's totally true, ATM it's impossible to require a crop :O That is not really hard to implement ! I can purpose a patch to assume this feature but I need you for define our real needed about it.
We add this option onto 'widget setting' as 'Crop required' to force user's to define a crop zone to save an entity ? We do add a check onto entity_insert/update basis or more hight level in form_element (I suppose yes...). Can we discuss more for not forget other implications about that ? These option do not be activate in same time of future Automated Crop or we just can add a check to ensure we have an automatic_crop configured onto style collection and our image are mendatory cropped.
Comment #5
O'Briat CreditAttribution: O'Briat at Capgemini for E.voyageurs Technologies, SNCF commentedHere's a patch that made all selected crops required.
It's a quick and dirty one : code reviews and unit tests are welcome
Needs a bit more work if you want only some of the crop to be mandatory.
Comment #6
O'Briat CreditAttribution: O'Briat at Capgemini for E.voyageurs Technologies, SNCF commentedComment #8
O'Briat CreditAttribution: O'Briat at Capgemini for E.voyageurs Technologies, SNCF commentedComment #9
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedA part of fails are fixed by #2887301: Fixe 2.x branch tests but I need to test more to tell you what is the problem here.
Comment #10
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedI re-run the test now tests are fixed.
Comment #12
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedre-roll correclty ...
Comment #13
O'Briat CreditAttribution: O'Briat at Capgemini for E.voyageurs Technologies, SNCF commentedAdd a missing FieldWidget file
Comment #14
sallakane CreditAttribution: sallakane at NeoLynk for Carrefour commentedHi, thank you for this patch it can be very useful.
On the other hand the control of the mandatory crop must be done with the backup of the node and not with the upload of the file, a small patch to correct this case.
Comment #15
sallakane CreditAttribution: sallakane at NeoLynk for Carrefour commentedHi,
After discussion with @woprrr I tried to optimize the code. Please let me know if there are any other changes.
Thx
Comment #16
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedThe patch isn't applicable onto 8.x branch please update your patch.
Thank @salla I review fast this patch
Comment #17
sallakane CreditAttribution: sallakane at NeoLynk for Carrefour commentedHi,
I reroll the patch, thank @woprrr for help.
Comment #18
sallakane CreditAttribution: sallakane at NeoLynk for Carrefour commentedComment #19
iampumaPatch #17 works on image_wdiget_crop 2.0.0. Thanks.
Comment #21
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedI think the following wording are more clear : "Set Crops as required"
same feedback about wording.
Actually I have a doubts about this. I explain why at the bottom because we need to choose the better way to implement that (Crop basis of Widget Basis).
This is useless because $element already have some mentions of type like key($element['crop_wrapper']);
We can increase the readability of code with only one line here.
setCropRequired(); seem better here.
self::requiredApplicable sound better as self::isRequired
This test works well in 80% of usecases but if I only need to set as required 1 of 3 crops available in this element I can't submit without save a crop in others elements. We need to identify where is the crop_type required like a boolean at CropType basis.
Here we really need to expose that configuration at ImageWidgetCrop widget basis ? If we attach this responsibility at CropType Basis we can delegate this here because if not we can't choose what crop type are required but all element are invalidate if we haven't all crops with values.
Actually we are in the good way to validate elements with required crops BUT we need to decide what is the best approach. If we force element to have ALL values completed to validate the element we risk to add more complexity in publish process.
I add @miro_dieker to this for have other thing about this possible border effect.
Comment #22
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedComment #23
drummUpdating to the canonical tag for DrupalCon Vienna 2017.
Comment #24
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedComment #25
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedMore specifications about solution Here #2912918: Possibility to define manual crop effect as required.
This patch isn't finished because we need to reduce complexity and coding standards fast. But the basis is already here and functional. Please continue in this way ;)
Comment #26
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedAfter somes discuss with @slashrsm , We have conclude Crop API doesn't assume "required' field at Crop Type basis because this responsability do be assume by UI modules and not by Storage.
I change that in patch and migrate that behavior onto field Widget configuration. Like initial purpose.
Comment #27
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHere a patch with the new way FieldWidgetBased to choose Required Crop by widget instance (Very powerfull for Site builder). Saddly I haven't more time to finish a small "refactor" of that If anyone can continue that's GREAT :)
The concept is to ensure we have all control of what Crop type is flagged require we have added a property (crop_types_required) to list on widget settings what crop_type are considered required for this field instance. For more simplicity and flexibility this list are populated by your choose onto previous element (crop_list) to be sure we required an active element and avoid complexity.
To test it we just need to choose what Crop type to apply to your image when you have selected your types the next list 'Set Crop Type as required' are populated with your crop types you can choose what crop type you need to be required to pass crop_image element validate.
Tomorow I will post a new screencast to show how that works. I need to have more feedbacks about that (code / usability) please.
I attach the patch to continue and add @TODO to illustrate what part I need to refactor.
Comment #28
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedThis part is now unecessary we need to retrieve this information with another way.
Options need to be [] empty at the begining and populate by user choose in crop list element.
Hummm obscure trick ... Halloween effect ?! We are mendatory to re-affect this process to save #multiple onto element if not add that the select are considered as #multiple => FALSE ...
We need to simplify this more and more ... Actually that works well but not really clear ...
Comment #29
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHere I think we are in the good way :). I flag issue need review to have more feedback by anyone need to make feedback but I need to add Functional test to cover these feature and create a follow-up to cover ALL usecases not already covered.
@miro_dietiker If you have a small time It's possible to have a meeting or mails about your opinion for that feature. I prepare a screencast to show how that works.
Thanks all.
Comment #31
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commented:D When you talk about Tests he's came :D
Comment #32
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHere a video to show How Required Crop works and how configure Crops with this patch.
https://youtu.be/X6gmJ162E5o
Comment #33
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHere you have some adjust to prevent all Miss configuration potential problems. I add that after a support session on Slack.
Here you are two adjusts to prevent miss configuration and UX improvements...
Comment #34
bdimaggio@woprr, at your request, some suggestions about wording. (Warning: a lot of this is very, very picky. I spent years as an ESL teacher and now I can't turn that part of my brain off. It's really terrible.)
I'd suggest 'No image style using the "manual crop" effect found. Please first go @link and attach the "manual crop" effect and then return to configure the field widget settings.'
The capitalization thing again.
I hope this helps! Happy to roll you a patch tomorrow with these changes incorporated, if that's useful to you.
Comment #35
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHey @bdimaggio :) THANK YOU for this wonderfull review ++++++
Here the patch with all fixes. Can you take a feedback about this interdiff ? :) Thank again !!
Comment #37
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedThe test failling is "normal" this is due to Image Widget Crop Examples sub modules dependencies. Ctools / Media entity use deprecated methods , I have already purpose patch in modules issue queue to solve this.
Comment #38
Peter MajmeskuWe are using this patch in our project on production since a longer time. Please commit it into the next release.
Comment #39
bdimaggioHey @woprrr, a belated RTBC from me too. Your wording/spelling/capitalization/etc looks great!
Comment #40
Peter MajmeskuI have noticed, that I get a lot of PHP warnings from below (the same, multiple times), when I am on a media entity edit page e.g. /media/MEDIA-ID/edit:
I think this needs fixing. Therefor I am opening this issue again.
Comment #41
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedHi @Peter Majmesku and thank to this pragmatic review :) This is important to correctly tested all features and transitions as possible before merge this important and waiting feature :). Sorry for this small miss the following patch solve this problems on two points.
First isRequiredType() do first check if the element hasCropRequired() and then parse the element configuration but that's more a consequence and a small adjust of element more than real patch.
Secondary we need to adjust Widget miss because element need to have an empty array and not NULL by default that's is forced to null in default definition of widget we need to change that (and for crop_list too by the way does suffer than same problems).
Can you test it again please and switch to RTBC if all works well to you :)
Thanks.
Comment #42
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedSmall fixe introduced conding standards issue sorry.
Comment #43
Peter MajmeskuI can confirm, that the warnings are disappearing after applying the current patch. Thanks to all!
This patch is RTBC!
Comment #45
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedMerged Thanks all :) good JOB
Comment #47
mogio_hh CreditAttribution: mogio_hh commentedmerged into dev?
Stable does not seem to include this patch.
When patching DEV or Stable I get an error:
Comment #48
nimoatwoodwayI had the same problem with current versions of drupal core 8.7.4 and module conditional_field 8.x-1.0-alpha5. Only first imagefield with crop thrown an error if cropping was not applied but all where marked with a red required *. After disabling and enabling conditional_field. Resave form display settings, field settings field suddenly it worked.