Focal Point is great. It lets site editors give Drupal information about which part of the image is important, and the system handles the rest.
Sometimes, I have found a case for "displacing" the set focal point slightly. This can be the case when the final image has overlayed text or is otherwise affected by the surrounding layout of the page. In this case, it may not be desirable to attempt to crop the image so the focal point is centered in the final image.
So I have added a "displacement" (edit:now called "shift") feature to the effects configuration, allowing editors (or whoever sets up the image styles) to add a set of integers that will shift the focal point in any direction during cropping. Here is an example:


Outstanding issues:
- The error message when entering invalid displacement values (eg. 0) is misleading.
- Tests.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | displace_the_focal-2386981-12.patch | 1.29 KB | rudins |
| #9 | displace_the_focal-2386981-9.patch | 8.19 KB | bleen |
| #6 | focal_point_shift-2386981-6.patch | 6.65 KB | achton |
Comments
Comment #1
bleen commentedI'm not sure about this feature... why dont you simply move the focal point indicator a little lower?
Comment #2
achtonHi Alex, thanks for your response.
There are several reasons for not moving the focal point.
1)
For one, I would be marking the wrong part of the picture as important with Focal Point. As an editor, I would be compensating for shortcomings in the site configuration by tweaking the focal point in order to make it crop the image the way I need, which would be bad path to follow.
Also, what if the image is reused in another context, with another image style that also uses focal point cropping and presents it differently? The way I had shifted the focal point might adversely affect every other instance of the image.
2)
Also, it's really not the responsibility of the editor who uploads content imagery to muck around with the cropping of the image - that's the whole point (no pun intended) of Focal Point.
3)
Most importantly, this feature lets the site builder/frontend developer/whoever knows the design actually *use* the information that will be set by editors in the future about the important part of an uploaded image. Use that information to push the focal point into an area of the cropped picture that makes sense according to the design and layout.
TL;DR:
I feel very strongly about the benefits of this module for content editors out there. They should not have to "pixel push" in order to achieve their tasks, that's the whole point of this feature.
Cheers,
Achton
Comment #3
elijah lynnThis looks like it could be useful in certain scenarios. And thank you very much for the inline screenshots!!
I would add that in most scenarios I don't see many with this usecase so I suggest to add the Displacement settings to an "Advanced settings" fieldgroup on the config.
Comment #4
bleen commentedI think @elijah lynn makes a good suggestion here. I'm trying very hard to keep the setup of this as well as the editorial experience as simple as humanly possible but I'm starting to see a place for this feature. I'm glad that the editorial experience is not affected at all...
Another note: I think "displacement" is an awkward term. "Offset" comes to mind, but in the code offset is used EVERYWHERE and has a different meaning. Thoughts?
Comment #5
achtonThanks for the feedback, I'll definitely work more on this and treat the feature as an "advanced feature" accordingly.
@bleen18: I did initially have this described in the UI and code as an "offset", until - as you mention - I discovered that offset is in use internally already.
Other suggestions: "Focal Point Offset X/Y" (would be `fp_offset` in code), or "Shift X/Y"?
I totally agree with the need for simplicity here, I'll try hard to retain that in the next patch.
Comment #6
achtonHere's a new version of the patch, now using the term "shift" instead of "displacement". I felt that any use of "offset" would muddle the in-code terminology unnecessarily, so I did not go that route. I think "shift" works better. I also added an "Advanced settings" fieldset for the config, and added the information to the effects overview page.
To summarize the patch, it now:
Comment #7
achtonComment #8
achtonComment #9
bleen commentedI made some minor changes:
Comment #11
bleen commentedOk .. I think this is good to go now.
Thanks acthton
Comment #12
rudins commentedStill not perfect. All image styles without 'focal_point_advanced' settings (created before) gives PHP notice. Notice: Undefined variable: shift_y in focal_point_effect_crop_data()
Comment #13
bleen commentedblarg! ... and I just created a release. Sigh. Testing now
Comment #15
bleen commented@rudins++