Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Let Wordpress make images in gallery block responsive / add srcset attribute #8593
Wordpress makes images with a wp-image-ID class responsive using a srcset attribute. This PR adds the needed class to the images in the gallery block. See #4898 for a similar fix for the image block.
Would help for #1450 because the browser should then only download the appropriate image sizes.
How has this been tested?
Upload images, create a gallery and view on the front-end. It should have added srcset attributes.
I've also run
Types of changes
My code adds the wp-image-ID class to the images in the gallery block. I also edited the wordpress-out.html test to reflect this change.
For reference, wp_make_content_images_responsive() adds the srcset attributes after it finds an image without srcset attribute and with a wp-image-ID class.
Another thing that can be done right now (before 6177) is to use the "large" image size by default (if it exists), then
Next step would be to look at the actual width of images and set