Problem/Motivation
This modules comes with a very nice UI. Focal point selector tool is currently coupled with image field. It would be very nice to be able to use it on other places too. One example would be file edit page that file_entity provides. There is even more. I believe this tool could be useful even outside of cropping problem. In every situation where some specific point on an image needs to be selected, for whatever reason, we could use the tool that this module provides.
Proposed resolution
I propose that we create a form element that will be responsible for focal point selection tool. Then we use this element on the image widget.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | convert_focal_point-2657592-15.patch | 35.05 KB | bleen |
| #17 | 2657592-17.patch | 36 KB | chr.fritsch |
Issue fork focal_point-2657592
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
chr.fritschHere is a first draft of the focal_point form element. I'am pretty sure that this is not ready, but i want to get some feedback to see if i'am on the right track.
Comment #3
spadxiii commentedIt might be an idea to wait until this is committed into dev: https://www.drupal.org/node/2701861
Comment #4
bleen commentedagreed
Comment #5
davy-r commentedJust a heads up, Create focal point specific image field widget is committed.
Plugin widget 'image_focal_point' is now available, changing the status accordingly.
Comment #6
tancIt looks like a good time to move onto this task now that #2701861: Create focal point specific image field widget is complete. Having a standalone form would reduce the code in #2701725: Integrate focal point with file entity and entity browser
Comment #7
bleen commentedBeen playing with this for a couple days... Hope to have a patch today
Comment #8
bleen commentedOk ... this is where I am at. The attached patch is not nearly finished. Things that are still problems:
Other than that, this is good to go ;)
Any help on this would be very much appreciated!!
Comment #9
bleen commentedThe focal point value is saved, but not displayed on the form properly. This is because "50,50" is hard coded in the focalpoint image widget process function.Comment #10
bleen commentedThis is definitely closer to how things should be, but still lots left to do:
The focal point value is saved, but not displayed on the form properly. This is because "50,50" is hard coded in the focalpoint image widget process function.The focal point value should ultimately work very similar to the "alt" value. It should travel with the image in the same way, but right now it doesn't.Comment #11
bleen commentedThe focal point value is saved, but not displayed on the form properly. This is because "50,50" is hard coded in the focalpoint image widget process function.By replacing the preview widget with the focal point element, the focal point value is referred to as "preview" in a lot of places. I think this should be fixed so that we remove the preview value and add the focal point value instead.The focal point value should ultimately work very similar to the "alt" value. It should travel with the image in the same way, but right now it doesn't.As is, this patch breaks the field-widget-based settings for "show preview link" and "default offsets"Comment #12
bleen commentedThe focal point value is saved, but not displayed on the form properly. This is because "50,50" is hard coded in the focalpoint image widget process function.There may (or may not) be a weird js issue where some bizarre errors show up ... needs more looking intoBy replacing the preview widget with the focal point element, the focal point value is referred to as "preview" in a lot of places. I think this should be fixed so that we remove the preview value and add the focal point value instead.The focal point value should ultimately work very similar to the "alt" value. It should travel with the image in the same way, but right now it doesn't.As is, this patch breaks the field-widget-based settings for "show preview link" and "default offsets"Focal point is showing up on the node/add form before an image is uploadedComment #13
tancNice work @bleen! Keep chipping away :)
Comment #14
bleen commentedThe focal point value is saved, but not displayed on the form properly. This is because "50,50" is hard coded in the focalpoint image widget process function.There may (or may not) be a weird js issue where some bizarre errors show up ... needs more looking intoBy replacing the preview widget with the focal point element, the focal point value is referred to as "preview" in a lot of places. I think this should be fixed so that we remove the preview value and add the focal point value instead.The focal point value should ultimately work very similar to the "alt" value. It should travel with the image in the same way, but right now it doesn't.As is, this patch breaks the field-widget-based settings for "show preview link" and "default offsets"Focal point is showing up on the node/add form before an image is uploadedDouble clicking on the focal point indicator shows the focal point field as it should (YAY!), but it breaks the form a bit (BOOO!)Comment #15
bleen commentedOk ... this is the first patch that I think *might* be ready. I did not add new TESTS since focal point really just needs a bunch of functional tests in general and that shouldn't hold this up any more than any other issue.
That said, this needs a lot of tire kicking. Please test it thoroughly....
Comment #16
kumkum29 commentedHello,
I reopen this post to know if the latest patch is included in the last version. Can we use Focal Point with the entity browser module?
Focal point module is very useful but actually not functionnal with entity browser.
Thanks.
Comment #17
chr.fritschHoly shit, this was a hell to rebase it. Hopefully, I did not destroy too much...
Comment #18
Coops_Patch #17 wasn't applying to the latest dev branch so I've updated it. Would be good to get this merged soon as well.
Comment #19
mikelutzAttempting a Re-roll of this, as I think I might find it useful.
Comment #21
swilmes commentedCan someone explain how one would use this patch to add a focal point image field to a form in code?
This produces a title and description but no image field.
Comment #22
duaelfrI'll try to reroll that in a MR
Comment #23
duaelfrComment #25
hudriWhen the field widget is converted into a standalone form element, this also completely changes the code needed to make this module potentially compatible with the SVG image module. Would love to see this merged soon, as this change is a blocker for issue 3122722
Comment #26
rajeshreeputracan someone please review and mark as RTBC, I have tested this but need second eye/hand.
Comment #27
martijn de witTried to apply https://git.drupalcode.org/project/focal_point/-/merge_requests/7.diff with composer at a 2.X version. But it seems composer can't handle the diff as patch...
Applied the diff manual with a git checkout (2.x version). It did apply. I see the deletion of
tests/src/Unit/FieldWidgets/FocalPointFieldWidgetTest.phpbut no replacing tests are added.I think if the behaviour is changed, a new test is needed. check?
Comment #29
ankitv18 commentedRebased with 2.x, re-rolled MR !7 and introduce DI in the service class.
Comment #30
ankitv18 commentedNeed to work on fixing the test cases.
Comment #31
ankitv18 commentedMR! 7 is ready for a review
Comment #32
rajeshreeputraLooks good to me, can we have another review on this.
Comment #33
martijn de witTrying MR #7.
Using media library via file field at a content type seems to go well... But when i'm going to [site]/media/add/image
I get an error:
Beside that I still don't see a replacement for the deletion of tests/src/Unit/FieldWidgets/FocalPointFieldWidgetTest.php. Because there is still a widget right?
Comment #34
ankitv18 commentedThanks for this quick review,
Will look into this!!
Comment #35
martijn de wit@ankitv18 did you already had some time to tackle #33 ?
Comment #36
martijn de witHiding patches because there is a recent Merge Request for this ticket.
Comment #37
martijn de witStill the problem for [site]/media/add/image is not resolved #33
Comment #38
martijn de witunassigning this, because there is no response (yet). and others already worked on it.
Tried to debug the latest version and get it working on [site]/media/add/image, but there is still a lot to do.