Selecting Image Size
-
Hi Stefan,
I’m having some confusion regarding the selected image sizes which i’m hoping you can clarify for me please.
My understanding is that by having different image sizes in the srcset, the browser will automatically choose the best size for the display device. So smaller image sizes for smaller screens, and larger sizes for larger screens.
I have tried to apply this logic to my homepage images by adding sizes for phone, tablet and pc screens based on how the image sizes change responsively for each device (including landscape/portrait orientations). I used the chrome extension “window resizer beta” to determine what these image sizes are.
This gives me the following sizes which i added to my functions.php
add_image_size( 'Homepage-iPad-Portrait', 676, 480 ); add_image_size( 'Homepage-iPad-Portrait@2x', 1352, 960 ); add_image_size( 'Homepage-iPad-Landscape', 285, 203 ); add_image_size( 'Homepage-iPad-Landscape@2x', 570, 406 ); add_image_size( 'Homepage-iPhone6-Portrait', 322, 229 ); add_image_size( 'Homepage-iPhone6-Portrait@2x', 644, 458 ); add_image_size( 'Homepage-iPhone6-Landscape', 585, 415 ); add_image_size( 'Homepage-iPhone6-Landscape@2x', 1170, 830 ); add_image_size( 'Homepage-iPhone5-Portrait', 273, 194 ); add_image_size( 'Homepage-iPhone5-Portrait@2x', 546, 388 ); add_image_size( 'Homepage-iPhone5-Landscape', 496, 352 ); add_image_size( 'Homepage-iPhone5-Landscape@2x', 992, 704 ); add_image_size( 'et-builder-portfolio-image@2x', 800, 568 );And the code i used for the homepage images was the one you gave before but now including these sizes:
<a href="<?php echo get_permalink( $post->ID );?>"> <?php $thumbnail_id = get_post_thumbnail_id( $post->ID ); echo rwp_img( $thumbnail_id, array ( 'sizes' => array( 'et-builder-portfolio-image@2x', 'Homepage-iPad-Portrait', 'Homepage-iPad-Portrait@2x', 'Homepage-iPad-Landscape', 'Homepage-iPad-Landscape@2x', 'Homepage-iPhone6-Portrait', 'Homepage-iPhone6-Portrait@2x', 'Homepage-iPhone6-Landscape', 'Homepage-iPhone6-Landscape@2x', 'Homepage-iPhone5-Portrait', 'Homepage-iPhone5-Portrait@2x', 'Homepage-iPhone5-Landscape', 'Homepage-iPhone5-Landscape@2x' ), ) ); ?> </a>The problem i’m having is that when i run Google PageSpeed Insights, it tells me my images need to be optimized. Specifically the larger sized images and retina images.
I’m confused as to why this is happening as i thought the whole point of having srcset was to be able to display different sized images to different sized screens. So i thought by doing what i’ve done my images would be optimized, but for some reason Google is saying they are not? I have the retina option enabled in Responsify Wp.
Am i missing something obvious here?
The topic ‘Selecting Image Size’ is closed to new replies.