Make WordPress Core

Opened 5 years ago

#47922 new defect (bug)

src attribute in Image Gallery Block is inconsistent with image inserted outside of gallery.

Reported by: bbogart's profile bbogart Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2.2
Component: Gallery Keywords:
Focuses: Cc:



  1. Create an Image Gallery Block.
  2. Upload an Image
  3. Select "Link To" "Media File"
  4. Preview / Publish post.

What I expect to happen:

A thumbnail of my uploaded image shown in the gallery that links to the original uploaded image. i.e. The behaviour should be consistent with images inserted outside of galleries.

I expect the resulting source to look like this: (The same as it would be if the image was outside of a gallery)

<figure class="wp-block-image"><a href=""><img src="" alt="" class="wp-image-4868" srcset=" 420w, 238w, 768w, 811w, 1109w" sizes="(max-width: 420px) 100vw, 420px" /></a></figure>

What actually happens:

The gallery uses the 1024x sized images that link to the same 1024px sized images, seemingly ignoring the "Link to" "Media File" specification. The 1024px down-scaled image seems to be selected arbitrarily and the visitor cannot access the full-sized image by clicking on the image in the gallery.

This is the corresponding source I actually get:

<figure><a href=""><img src="" alt="" data-id="4868" data-link="" class="wp-image-4868" srcset=" 811w, 420w, 238w, 768w, 1109w" sizes="(max-width: 811px) 100vw, 811px" /></a></figure>

Seems the offending issues are that:

  1. the href points to the down-scaled image, not the media file.
  2. sizes="(max-width: 811px) 100vw, 811px" when it should be sizes="(max-width: 420px) 100vw, 420px" where 420px is my default thumbnail size.

Change History (0)

Note: See TracTickets for help on using tickets.