Nick J.
Nick J.

Reputation: 71

Wordpress: choose an image size when creating an image gallery

Goal: When creating an image gallery in Wordpress 5.3.2 using the Gutenberg editor, I'd like to be able to select the image size.

Why: The block gallery automatically serves the large image and then relies on CSS to resize the image to fit the flexbox layout. Instead I'd like to choose the medium size for my site, which is closer in size to what's displayed in the layout. This will improve load times, as users aren't being served oversized images.

Question: Is there some code I can add to functions.php that will give me the option to choose the image size I want or to override the default large size for the medium size?

Upvotes: 0

Views: 89

Answers (1)

Will
Will

Reputation: 878

I understand what you're going for and unfortunately WordPress and Gutenberg still loads the full-size, original image (and just resizes it in css) :(

There are several closely-related issues that describe this

Update, 2021:

Gutenberg no longer loads the full-size, original image and you can choose which in the block's right side panel which of the registered image sizes to load; but that image is often still larger than necessary and not fully optimized; more information at https://gist.github.com/skorasaurus/a01249d4302226bf12c80dd979322303

Upvotes: 1

Related Questions