Apply default pattern generation from first image instead of last #398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With our current default pattern generation, we overwrite
$bindings['image']['url']
and$bindings['image']['alt']
each time we encounter a new one. I'm working with a data source that returns several images, with some of them being optional. The configuration output mapping looks like this:I have the primary image URL and alt text at the top of the configuration, and some optional variant possibilities below. Prior to this PR, the auto-generated image that's selected by the default pattern would be
Variant3Image__c
(the least likely to have a value in my case) andimage_url
is never used.This PR changes pattern generation to keep data about all images and instead construct the default pattern from the first encountered image and alt text. Note that this may cause the primary image's alt text to match an unrelated alt text from another part of the config, because bindings are evaluated individually. However, this is the same behavior as the current pattern generation so this is not a regression.