Archived topic
Custom thumbnail size to improve Google PageSpeed Score
3 replies · Started by Sergio on September 5, 2018
Hello there,
I´m trying to improve my overall score in Google PageSpeed Insights. One of the main issues I´m facing is optimizing images. I have a lightbox gallery that I want to choose a custom crop size, not the regular Thumbnail, Medium or Large. I found these two codes online, what are the main differences and which one works better?
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
add_image_size( 'custom-name', 390, 250, true );
}
add_action('after_setup_theme', 'tu_add_image_sizes');
function tu_add_image_sizes() {
add_image_size( 'custom-name', 390, 250 );
}
Hi there,
Where are these images coming from? Are they featured images? Images inside your content?
Let me know :)
Inside a section on Elementor, I added a gallery. It displays the images like a grid, 3 columns and 2 rows. The browser loads them at 390x250px, but they are actually 1000x641px because lightbox is activated, that the warning I get on PSI. Elementor only allows my to choose a resize dimension offered by my theme, which is GeneratePress. I´m assuming I have to add the function in my functions.php. I was more clear?
Hi there,
the second code you provided will register the custom-name thumbnail size.
You will then need to regenerate your thumbnails for that size to be useable. You will need this: