Skip to main content

G_AUTO automatically added - TURN OFF

Comments

1 comment

  • Loic Verger Del Bove

    Hi Nemanja,

    Thanks for reaching out.

    This is automatic when adding width and height to your image element. You can modify it by adding this piece of code to your functions.php

    /**
    * Granular control on Cloudinary crops.
    *
    * @param array|string $size The size array or slug.
    * @param int $attachment_id The attachment ID.
    *
    * @return array|string
    */
    add_filter(
    'cloudinary_prepare_size',
    function ( $size, $attachment_id ) {
    if (
    is_array( $size ) &&
    (
    // Check more about WordPress conditionals here https://developer.wordpress.org/themes/basics/conditional-tags/.
    is_post_type_archive( 'product' ) ||
    // Check more specific WooCommerce conditionals here https://docs.woocommerce.com/document/conditional-tags/.
    is_woocommerce() ||
    // Check specific requested image sizes.
    'woocommerce_thumbnail' === $size['wpsize']
    )
    ) {
    $size['crop'] = 'scale';
    unset( $size['gravity'] );
    }

    return $size;
    },
    10,
    2
    );

    This code is for WooCommerce, so you might need to add a condition depending on how your images are added

    Hope that helps.

    Best,

    Loic

    0

Post is closed for comments.