[wp-trac] [WordPress Trac] #61066: Add "cover" cropping mode for custom image sizes

WordPress Trac noreply at wordpress.org
Wed Apr 24 09:33:50 UTC 2024


#61066: Add "cover" cropping mode for custom image sizes
-------------------------+-----------------------------
 Reporter:  jefferyto    |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Media        |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 When developing a custom theme, sometimes images are shown, not to display
 them in their entirety, but to "fill in" an area with a graphical element.

 For example, the category/tag archive page may be designed to have a
 thumbnail area next to each post title. Often, the design goal is to have
 the thumbnail area entirely covered with an image; whether the whole post
 thumbnail is visible is not important.

 The current "soft" cropping mode for custom image sizes do not cater to
 this use-case.

 Using the above example (post thumbnails on an archive page), suppose the
 thumbnail area is 200px x 200px and the theme adds a custom 200x200 image
 size:

 {{{#!php
 add_image_size( 'custom-size', 200, 200 );
 }}}

 If the user uploads a 600x400 image, then WordPress will generate a
 200x133 version of the image. This version is not large enough to cover
 the 200x200 thumbnail area.

 In other words, the current "soft" cropping mode enforces a maximum image
 size. Using CSS terms, this corresponds to the `contain` keyword for
 `background-size` and `object-fit`.

 What this enhancement request is asking for is a "cover" cropping mode
 that enforces a minimum image size, to be used with `background-size:
 cover` or `object-fit: cover`.

 In the above example of a 600x400 image, this "cover" cropping mode would
 generate a 300x200 version. This version would be large enough to cover
 the 200x200 thumbnail area.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61066>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list