2

I'm using a theme which displays a grid of images, but it only works with landscape images at the moment (with portrait images, people's heads are cut off).

The theme uses custom featured image sizes defined in functions.php through the use of add_image_size().

Is there a way to set the image sizes proportionately to maintain the correct aspect ratio?

  • How is image size registered verbatim? It should default to "soft" proportional crop. – Rarst Jun 11 '14 at 18:28
  • If your are running WordPress 3.9+ you an also set the crop position which is helpful for working with portrait style images. You can see how in this article on WPexplorer. – Matt Royal Jun 11 '14 at 18:48
3

The code of WordPress states that the fourth variable with the add_image_size() function is value for the crop 'mode'.

If you that value to 'false' (which is default) it'll keep the aspect ratio of your images.

For example, if you set height and width to both 150x150 and have an image that is 300x200 will become 225x150.

Source: http://codex.wordpress.org/Function_Reference/add_image_size

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy