Update card media deprecation to check both src and attributes.src #2585
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.
Jira
https://pegadigitalit.atlassian.net/browse/DS-903
Summary
Fixes deprecation logic for image in cards
Details
#2520 introduced a check for usage of the deprecated image component.
The check didn't take into account the possibility that a
src
prop could be passed either directly or asattributes.src
. In the later case, the logic incorrectly assumed that a render array was being passed rather than structured data.Ultimately, this should be fixed on the Drupal side, but this update fixes the break.
How to test
On a local Drupal site, find a page that has cards with images and is exhibiting the above error after updating to Bolt 5.8.0.
Manually copy the change in this PR to the docroot/bolt/twig/packages/components/bolt-card-replacement/src/card-replacement-media/_card-replacement-media.twig. Clear caches, reload the page, and confirm errors are gone and card images display as expected.