Problem/Motivation
Embed mode ignores the focal point when the requested crop box is at least as large as
the source: getFocalPointCropParameters() returns an empty array, so the widen.net URL
carries no crop parameters at all instead of letterboxing the way Drupal's own image
pipeline does. Separately, a focal point set in Embed mode is not carried onto the
Download-and-sync file crop, and one set with the native image widget in
Download-and-sync mode is not carried onto the embed styles, so switching a media type's
render mode loses it.
Steps to reproduce
1. Create an image style with a focal_point_crop effect, e.g. width 3000 height 2000, and
attach it to a media type using the Acquia DAM embed code formatter. Use an asset larger
than 2048px, e.g. 4000x3000, and set a focal point on the media item.
2. Render the media item and inspect the generated widen.net URL. Source dimensions cap to
2048x1536, the 3000x2000 box caps to 2048x2000, so 2000 >= 1536 and no parameters are
emitted.
3. On a media type with download_assets enabled and the same 4000x3000 asset, set a focal
point with the native image widget, then switch the type to embed mode (or inspect the
embed crops directly).
Expected: the URL is letterboxed into the requested box (crop=no, w, h, color), matching
Drupal's own rendering of the same style; and the focal point follows the asset across
render modes.
Actual: the URL contains no crop parameters and the uncropped original is displayed with
the focal point ignored; and the focal point exists only in the mode where it was set.
Proposed resolution
Return letterbox parameters instead of an empty array when the box reaches or exceeds the
source, after capping the requested box with getDimensionValue() (2048px) so the
comparison matches every other branch in mapImageEffects(). Split the focal point
conversions by coordinate space - ...Embed() methods for "acquia-dam://styles/..." rows
(2048px clamped) and ...File() methods for local file crops (true pixels) - and add
setFocalPointOnFile() / syncFocalPointFromFileToEmbedStyles() to carry a focal point
between them, guarded so a file crop the editor set is never overwritten. Also cast the
anchor offset to int and guard a zero source width (DivisionByZeroError).
User interface changes
None. The focal point element stays embed-only; no form elements are added or altered.
API changes
relativeToAbsolute() / absoluteToRelative() are renamed to relativeToAbsoluteEmbed() /
absoluteToRelativeEmbed(), the CropInterface parameter and internal save are dropped, and
persistence moves to applyAbsoluteToCrop(). New public methods: relativeToAbsoluteFile(),
absoluteToRelativeFile(), setFocalPointOnFile(),
syncFocalPointFromFileToEmbedStyles(), getDownloadedFile(), getImageDimensions(). No
deprecated wrappers are included; happy to add them for one release if preferred.
Behaviour change to note: for a style whose crop box reaches or exceeds the capped source,
the embed URL changes from no crop parameters to crop=no&w=...&h=...&color=000000.
Data model changes
None. No new entity types, fields, schema or configuration.
Issue fork acquia_dam-3624193
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 #1
rohan-sinha commented.
Comment #2
rohan-sinha commented.
Comment #3
rohan-sinha commented.
Comment #7
rajeshreeputraMR merged!