• Resolved candell

    (@candell)


    I’m having a serious mind melt.

    I need images to be cropped on upload to be 300×300, but show the whole image.

    For example, a tall and thin image will be 300px tall and show the whole image.

    A short but wide image will be 300px wide and show the whole image.

    Currently all images are cropped to the middle portion of the image.

    Is it also possible to have whitespace around the image to make a tall and thin image 300×300 instead of 100×300 for example?

    The issue is highlighted most in Woocommmerce using the image setting from Customizer. I have thumbanil width set to 300 and 1:1.

    I’m not too fussed about width, I want to set the height mostly.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You’re describing scaling. Cropping means some portion of the image will be lost. Sorry for being pedantic, but it’s an important distinction in addressing your need. You can register a new 300×300 image size that is not cropped, but scaled.
    https://developer.www.ads-software.com/reference/functions/add_image_size/

    The new size will be used in new uploads, not existing images. There are plugins that will update existing images to a new image size scheme. As far as adding background fill to unused space to reach 300×300, it might be possible if your server has the Imagick image editor module. Most only have the GD editor where I doubt it’s possible. In any case, it’s not part of WP functionality, it’d need to be custom coded. I recommend using HTML and CSS to display a square, filled background for rectangular images.

    Thread Starter candell

    (@candell)

    Thanks, scaling is exactly what I needed to hear and have it sorted now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Image sizes help’ is closed to new replies.