• I am using Jetpack with Photon on.
    I am using hard-crop on featured images like this :

    `add_theme_support( ‘post-thumbnails’ );
    set_post_thumbnail_size ( 635, 200, true );`

    I have no other settings for wordpress srcset or sizes in my functions.php.
    So wordpress generates the srcsets for a featured image uploaded with resolution 1500×1048 as follows:

    srcset="link-to-image?zoom=2&resize=635%2C200 1207w, link-to-image?zoom=3&resize=635%2C200 1905w" sizes="(max-width: 635px) 100vw, 635px

    So it basically crops the image to 635 and then generates 2 versions of it, zoomed from 635 to 1207 and 1905. And needless to say that it loads the 1207 version for sizes smaller than 1905… even on 100×100 device screen it still loads 1207 width image.

    Can you please advice on how to set srcset and sizes in functions.php (only for featured imgs) for a site with featured images maximum 635px on any device? But I would still want some srcset for retina if possible.

    • This topic was modified 8 years, 1 month ago by grimox.
    • This topic was modified 8 years, 1 month ago by grimox.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    These 2 srcset values are indeed to be expected: Photon adds those 2 values (zoom 3 and zoom 4) when possible, to offer larger images on Retina devices.

    even on 100×100 device screen it still loads 1207 width image.

    That seems to be the issue here. In addition to the 2 srcset values above, you should also get srcset values from WordPress itself, for smaller versions of the image. Photon doesn’t remove those original srcset` values provided by WordPress, it only tweaks them to use Photon. However, they appear to be missing from your example above.

    Could you post a link to one of the pages where the post thumbnails are displayed, so I can take a closer look?
    If you want your site URL to remain private, you can also contact us via this contact form:
    https://jetpack.com/contact-support/

    Could you also let me know if you use other plugins that may impact the srcset values returned by WordPress?

    Thanks!

    Thread Starter grimox

    (@grimox)

    Thank you for your answer.
    I sent you the site URL via contact form. I forgot to mention there the active plugins :
    Facebook, Google Authentificator, Jetpack and Loginizer.

    As an adition to my first post I would like to mention that all the featured images no matter the resolution they are uploaded, have only the 1207w and 1905w srcsets. But the images uploaded with width lower than 1207 in the chrome dev tools > network tab download as 635px width where the images uploaded with width higher than 1207 download as either 1207 or 1905 depending on device screen size.
    The problem is strictly with the hard crop feature because if I deactivate that the images get the default wordpress srcsets.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I sent you the site URL via contact form

    Thanks! We’ll get back to you soon!

    all the featured images no matter the resolution they are uploaded, have only the 1207w and 1905w srcsets.

    That seems to be the issue here. Does this happen even when you deactivate Photon?

    Thread Starter grimox

    (@grimox)

    You are right, it is something wrong with wordpress not jetpack, I deleted Jetpack completely and there is no srcset on the thumbnails. I will investigate the issue further on wordpress side. Thank you for your time.
    If you have any ideea on why wordpress adds no srcset on thumbnails would be greatly appreciated.

    • This reply was modified 8 years, 1 month ago by grimox.
    • This reply was modified 8 years, 1 month ago by grimox.
    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I’m not sure what could cause this. Do you use a custom function to display those thumbnails on the page? What happens if you use something like the_post_thumbnail() (#) instead?

    Thread Starter grimox

    (@grimox)

    Thank you for your support.
    I am using hard-crop on featured images in my functions.php file like this :

    function srcset_test() { 
    add_theme_support( 'post-thumbnails' ); 
    add_image_size( 'custom-thumbnail', 635, 230, true ); } 
    add_action( 'after_setup_theme', 'srcset_test' );

    I have no other plugin installed, not even Jetpack. No matter how large the image I upload wordpress won’t add srcset for my cropped featured images.

    The problem seems to be with hard crop feature because the srcset shows correctly on any other image posted in article (from media for example). If I deactivate the hard crop the srcset shows correctly on the thumbnails too.
    I am having this problem in both twentysixteen and twentyfifteen themes with no modification but the hard crop one.

    • This reply was modified 8 years, 1 month ago by grimox.
    • This reply was modified 8 years, 1 month ago by grimox.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Jetpack photon srcset for custom thumbnail’ is closed to new replies.