• Resolved wesleylancel

    (@wesleylancel)


    When enabling image optimisation through Jetpack’s CDN it seems to change the size of my Woocommerce product thumbnails which are set as squares of 100×100. After enabling the option the width stays 100 but the aspect ratio of the original image is maintained so they’re no longer square.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @wesleylancel

    Could you post your site URL here, so I can have a look?
    ?
    If you want it to remain private, you can also contact us via this contact form:
    Contact Support. Thanks!

    Thread Starter wesleylancel

    (@wesleylancel)

    Hi @erania-pinnera!

    Sure, a URL to a product detail page: https://www.gamlindarts.be/webshop/product/arrow-greens-20-nikkel-zilver/

    You can see the product thumbnails have different sizes. When disabling Jetpack’s image CDN they’re all squares.

    Anonymous User 18700194

    (@anonymized-18700194)

    Thanks for the additional information.

    We’re taking a look at this and will get back to you soon with an update.

    Thread Starter wesleylancel

    (@wesleylancel)

    Hi @bobmatyas,

    Thanks for taking a look. In the meantime, can I turn off the feature or do you need it enabled to investigate?

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi @wesleylancel,

    Apologies for the late reply, we’ve been trying to replicate the issue at our end with no great success. It looks like it’s quite a peculiar issue that’s not easy to get replicated.

    We dug a little further on that, and my main suspects fall into a timing problem: the WooCommerce script could be running before the Jetpack script, hence the WooCommerce script doesn’t see an image yet.

    There are a couple of options you can try out – I’ll list the easier and then the more complicated one.

    – try using the Regenerate Thumbnails plugin: it worked beautifully in some cases.

    – if that ^^ won’t help, then you can try adding a filter in the function.php file:

    add_filter( 'wp_get_attachment_image_attributes',function ($attributes, $attachment, $size){ if ( $attachment ) { $src = image_downsize( $attachment->ID, $size ); if ( $src ) { $attributes['srcwidth'] = $src[1]; $attributes['srcheight'] = $src[2]; } } return $attributes; },10, 3 );
    
    add_filter( 'jetpack_lazy_images_new_attributes',function ($attributes){ if ( !empty( $attributes['srcwidth'] ) && !empty( $attributes['srcheight'] )){ $attributes['srcset'] = "data:image/svg+xml,%3Csvg xmlns='https://www.w3.org/2000/svg' viewBox='0 0 ".$attributes['srcwidth']." ".$attributes['srcheight']." '%3E%3C/svg%3E"; } return $attributes; } );

    This has been documented in this GitHub issue, so I trust it could work in your site too ??

    You can use a plugin such as Code Snippets to add the filter above to your site:

    https://www.ads-software.com/plugins/code-snippets/

    Hope that’s all clear. Let us know how it goes!

    Anonymous User 18700194

    (@anonymized-18700194)

    Hi there,

    It has been more than one week since we have heard from you, so I’m marking this topic as resolved.

    But if you have any further questions or need some more help, you’re welcome to reply here or open another thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Jetpack CDN changing image size’ is closed to new replies.