When using the text overlay effect, we can use tokens. During that token replacement, there are various opportunities for other modules to provide and alter the token replacements with hook_tokens() and hook_tokens_alter().

It would be nice to pass all the context we have into the token replacement process, to give other modules an opportunity to make the best token replacements as possible.

Comments

jfrederick created an issue. See original summary.

jfrederick’s picture

Status: Active » Needs review
StatusFileSize
new2.08 KB

And a patch

mondrake’s picture

Tokens are not my favorite playground, so I hope @Berdir or @slashrsm can review this.

The one thing that jumps out to me: the token replacement is done in the ::getTextWrapper method for a reason - it is called by both ::applyEffect and ::transformDimensions.

Now, ::applyEffect has an image object in input, but ::transformDimension has not - because the latter is meant to precalculate derivative image dimensions without the IO load that fetching an image object brings.

So, potentially this patch introduces the risk that the two methods will return different dimensions, which we should avoid.

An option could be, instead of passing the image object to the token context, to pass an associative array with the elements that may be used by the token system, like e.g. height, width, uri - and that to be taken from the image object in ::applyEffect, and from the passed arguments in ::transformDimensions.

mondrake’s picture

Issue tags: +D8Media, +Media Initiative

tagging

a_khalipau’s picture

StatusFileSize
new1.75 KB

Ported to the latest version.

mondrake’s picture

Status: Needs review » Closed (outdated)