1

I created an image size:

add_image_size('slider', 1920, 1080, true);

Now, i thought hard cropping meant that WordPress would zoom into the picture until it obtains that size and proportion no matter what.

Well, if User enters a vertical image, say 784x1200, What WordPress is doing is getting me an 784x1080 image, so it ignores the asked width because it matches height first??

2 Answers 2

1

First, let's check the behavior of cropping. According to code reference:

  1. If false (default), images will be scaled, not cropped.

    1. If an array in the form of array( x_crop_position, y_crop_position ):

      • x_crop_position accepts left, center, or right.
      • y_crop_position accepts top, center, or bottom. Images will be cropped to the specified dimensions within the defined crop area.
    2. If true, images will be cropped to the specified dimensions using center positions.

So, here's what's gonna happen when you set the dimensions to 1920x1080 and then upload an image:

  • If both width and height of the image are larger, the image will be cropped as 1920/1080 (Or 16/9) by its center and then resized to 1920x1080.
  • If one of the image's dimensions are larger than 1920 or 1080, then the larger side will be cropped to match the appropriate side, and the other side will be untouched.
  • If none of the sides are larger than 1920 or 1080, no thumbnail will be generated.
1

WordPress can't make images bigger when they crop. If an image is smaller than a given image size, the image won't be made for that size. For example, if you upload - 200x200 image, a 150x150 thumbnail will be made, but a 300x300 medium size won't be. If you upload a 400x100 image, a 300x75 medium image will be made, but the thumbnail will only resize and crop the axis that is big enough, you'll get. 150x100 thumbnail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.