WordPress.org

Make WordPress Core

Opened 2 months ago

#47922 new defect (bug)

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

Reported by: bbogart Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2.2
Component: Gallery Keywords:
Focuses: Cc:
PR Number:

Description

Steps:

  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="http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5.png"><img src="http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-420x530.png" alt="" class="wp-image-4868" srcset="http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-420x530.png 420w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-238x300.png 238w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-768x970.png 768w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-811x1024.png 811w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5.png 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="http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-811x1024.png"><img src="http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-811x1024.png" alt="" data-id="4868" data-link="http://www.ekran.org/ben/wp/2019/early-full-resolution-explorations/23-sigma35-e0-5/" class="wp-image-4868" srcset="http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-811x1024.png 811w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-420x530.png 420w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-238x300.png 238w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5-768x970.png 768w, http://www.ekran.org/ben/wp/wp-content/uploads/2019/08/23.sigma35.e0.5.png 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.