media_contextual_crop_preprocess_responsive_image ignores $variables['sources'] if they are set

Created on 9 February 2024, 10 months ago
Updated 12 February 2024, 10 months ago

Problem/Motivation

The context of this issue is Drupal 10.2.3 running on PHP 8.2

We are using a core responsive image style with a theme defined breakpoint group, and one image style per breakpoint, and fallback image style. This image style is rendered with the core Responsive image formatter.

In Drupal 10.2 this formatter stores the src-set images in an array called $sources, and these are not replaced in media_contextual_crop_preprocess_responsive_image method.

Proposed resolution

See fork with MR

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇳🇱Netherlands rené bakx Netherlands

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

Merge Requests

Comments & Activities

  • Issue created by @rené bakx
  • 🇳🇱Netherlands rené bakx Netherlands

    While working on the MR I noticed that a single responsive image style can have multiple images with a extra sizes rule, so I adjusted my original version to handle those as well.

  • Status changed to Needs review 10 months ago
  • 🇳🇱Netherlands rené bakx Netherlands
  • 🇫🇷France DrDam

    Thanks for the MR, I really need reviews on the image_responsive feature.

    Thanks for the tweet too.

  • Status changed to Fixed 10 months ago
  • 🇳🇱Netherlands rené bakx Netherlands

    Thanks for your rapid action :)

    We are going to move forward in production with this contextual system, so if we find more issues I will try to fix them as well.
    Like I said in the tweet (for those who read along with X), contextual media is the missing link in Drupal media management. Upload image once, use multiple versions with their own crop.

  • Status changed to Fixed 10 months ago
  • 🇳🇱Netherlands rené bakx Netherlands

    Guess the next action is closing this issue :)

  • 🇫🇷France DrDam

    Thank you for your confidence in this solution.

    Just remain aware that this is first and foremost a PoC and a demonstrator that the need exists and that it is not just “a whim”.

    I regularly update all the modules in the collection, so I encourage you to regularly test and check that I don't break anything.

    Thanks again for the trust.

Production build 0.71.5 2024