[Resolved] Hard Crop Woocommerce Single Product Image?

Home Forums Support [Resolved] Hard Crop Woocommerce Single Product Image?

Home Forums Support Hard Crop Woocommerce Single Product Image?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2297195
    Aaron

    Hello,
    I see settings to set the image size, but it says the images will remain uncropped. Is there a way to hard crop them to be square?

    Unfortunately it won’t work to ask the store manager to manually crop images before uploading.

    Thanks

    #2297241
    David
    Staff
    Customer Support

    Hi there,

    Woocommerce provides some Hooks to filter the sizes of the images it displays – see here:

    https://woocommerce.com/document/image-sizes-theme-developers/#section-3

    A working example would be something like this:

    add_filter( 'woocommerce_get_image_size_single', function( $size ) {
     return array(
      'width' => 600,
      'height' => 600,
      'crop' => 1,
     );
    } );

    You may need to run the Regenerate Thumbnails plugin afterwards to regenerate the new size, and clear any caches.

    But…. if i may say, its not a good method especially if you have many images of various aspect ratios, theres no logic or smart algorithms that define where or how to crop an image, so the end results may not be great. The best method is to crop the images before uploading…..

    #2297253
    Aaron

    Hi,
    Great thanks! I’d love to have them upload cropped images, but this will be a good fall back.

    #2297275
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.