Linking breaks responsive image formats

Created on 7 February 2021, almost 4 years ago
Updated 12 April 2024, 8 months ago

Problem/Motivation

Working with Drupal 9, I'm making a 'preview' for a custom content type that provides an image (using the core Media module) with a caption and next/previous links. The preview display is intended to be embedded in other nodes. I want to make the image a link to the image page itself.

This all works fine, unless the image is being displayed with a responsive image format. In that case, the sizes attribute gets truncated, to only the portion after the last min-width media selector, completely breaking the whole responsive image specification. I suspect that it's actually the colon after the min-width that is the problem, as that seems to be a more likely target for munging than the string 'min-width:' as a whole.

Steps to reproduce

I haven't tried a minimum reproduction, but if I'm right this should happen literally any time you use this module to wrap an image that has a responsive image style selected.

Proposed resolution

I've reviewed the code that does this, which appears to be the same in 8.x-1.3 and in 8.x-dev, which isn't surprising given the commit history, and I cannot see anywhere in this module's code that this would be happening.

In fact, the module doesn't appear to treat any attributes differently from one another on an img tag, and yet I can't reproduce the problem with the alt attribute. So frankly, I'm confused.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Documentation

Created by

πŸ‡¬πŸ‡§United Kingdom sambc

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024