Archived topic
Image sizes
3 replies · Started by Erlend on February 22, 2021
Hi,
I'm using the latest version od GPP together with the Mellow theme from the site library. By default, the theme uses a sitewide hero and a 700px wide content area. The thing I'm struggling with is getting the pictures used in the most optimal way (dimensions and file size).
For starters, when I upload a picture (2000 x 1333px, 594 kb) via the media library, automatically a few other sizes are created as well. Not sure whether this is default Wordpress, GPP, or a combination. Strangely enough, the 1536 and 1024 px wide versions are actually bigger in size than the 2000px original: https://www.screencast.com/t/nKVpeoDI3lc9 Is there a way to solve this problem?
As you can see, it also created a 768px wide version of the original. However, the theme doesn't use that for a full width content picture, but instead prefers the much bigger 1024px version with the alias Large in the block properties. I can't choose the more suitable 768px version.
In the forum, I also found a script to make wordpress generate custom size, so I added that to the function file. It did create the 700px version, but again no way to select it, nor does the theme select it automatically because the size is a perfect match.
Any help on this would be much appreciated.
Kind regards,
Erlend
Hi there,
the generation of the various image sizes is a core WP function.
Likewise any sizes you register and their display as options within the editor are also controlled by WP. They should show up automatically with the default sizes.
Any selected image size will be output using src-set in the images HTML, this will include all sizes smaller than the original image size. The browser will select the appropriate sized images.
When it comes to the Header Element that image is being displayed as a CSS background image, which there are no selectable sizes or src-set... you can change which image GP will load using this PHP Snippet:
add_filter( 'generate_hero_thumbnail_id_size', function() {
return 'full';
} );
Just change to full to the size you require eg. medium-large
https://docs.generatepress.com/article/adding-php/
Sorry the Screencast you provided is just a list of adwords....
Hi David,
Thanks a lot for the reply, and sorry for the wrong screencast url, I updated it.
The new size I defined doesn't show up automatically, but I'll read up on that in Wordpress forums since you say this is core WP.
Kind regards,
Erlend
You're welcome.
See here regarding the larger Image File Sizes: