- Issue created by @dalin
- First commit to issue fork.
- Merge request !473424683: Provide hook_focal_point_entity_update_alter → (Open) created by geoffreyr
- 🇦🇺Australia geoffreyr
We needed to do this for our use case, so we patched Focal Point to allow us to hook into the focal point values before they get saved. This might allow for some variety of solutions, whether they be backend, remote, or frontend.
- 🇲🇽Mexico dalin 🇨🇦, 🇲🇽, 🌍
@geoffreyr
Interesting.While your approach is fundamentally different than the original thrust of this issue, I can see how a back-end hook could be useful (though probably as a different issue on d.o). Some thoughts:
* It should probably only re-save the crop if the values have changed.
* To create a whole system of plugins on top of Focal Point (that can interact with its hooks and add additional settings) might be overkill if Focal Point was just awesome out-of-the-box. Typically you shouldn't create the abstraction layer until you have 2–3 use cases with valuable divergence. - 🇦🇺Australia geoffreyr
@dalin Thanks for the feedback! I appreciate that adding a whole plugin system does run the risk of overcomplicating things. Perhaps this sort of functionality might be more useful attached to Crop module itself -- that way, it could work with other methods of cropping, such as cloud solutions that provide smart crop bounding boxes instead of focal points. This might also help get around the issues with Image Widget Crop pre-emptively removing the Focal Point crop.
In our hook implementation we check
$crop->isNew()
before updating the coordinates, so perhaps I should update the patch with either the same behaviour or explicitly check whether the crop coordinates have changed, as you suggested.Lot to think about here. I'll see what I can do to make this more useful.