If attributes passed to responsive_image have mixed destinations, one or the other will not show up

Created on 18 June 2024, 5 months ago
Updated 2 July 2024, 5 months ago

Problem/Motivation

If attributes passed to responsive_image have mixed destinations, one or the other will not show up.

Steps to reproduce

Pass a mixture of attributes to a responsive_image element, some of which are configured to be placed on <img> and some of which are not. For example:

[
  'itemprop' => 'foobar',
  'data-my-attribute' => 'my value',
]

Either only the <img> or only the <picture> attributes will actually be passed to Twig.

Proposed resolution

In media_helper_preprocess_responsive_image() there is a foreach loop that sets $tag_attributes = NULL near its beginning. This variable is assigned to a reference and potentially re-used across cycles. It needs to be unset() at the end of the cycle so that the beginning of one cycle does not clobber the other.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bvoynick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024