[wp-trac] [WordPress Trac] #61066: Add "cover" cropping mode for custom image sizes
WordPress Trac
noreply at wordpress.org
Wed May 1 15:22:51 UTC 2024
#61066: Add "cover" cropping mode for custom image sizes
-------------------------+----------------------
Reporter: jefferyto | Owner: (none)
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: Media | Version:
Severity: normal | Resolution: invalid
Keywords: | Focuses:
-------------------------+----------------------
Changes (by joedolson):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Hi! Thanks for reporting an issue!
In fact, WordPress already supports this. The 4th parameter of the
`add_image_size()` function sets the crop behavior. See
[https://developer.wordpress.org/reference/functions/add_image_size/
add_image_size()] in the function documentation.
Essentially, you'll want something like `add_image_size( 'custom-size',
200, 200, true );`, to do a hard crop from the center of the image, or
`add_image_size( 'custom-size', 200, 200, array( 'left', 'top' ) );` to do
your hard crop from the top left corner, etc.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61066#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list