Create multiple smaller images from a single source.
Attempts to create all sub-sizes and returns the meta data at the end. This may result in the server running out of resources. When it fails there may be few "orphaned" images left over as the meta data is never returned and saved.
As of 5.3.0 the preferred way to do this is with make_subsize(). It creates the new images one at a time and allows for the meta data to be saved after each new image is created.
$sizesarrayrequired
...$0 arraywidth int$height is specified.height int$width is specified.crop bool|arraypublic function multi_resize( $sizes ) {
$metadata = array();
foreach ( $sizes as $size => $size_data ) {
$meta = $this->make_subsize( $size_data );
if ( ! is_wp_error( $meta ) ) {
$metadata[ $size ] = $meta;
}
}
return $metadata;
}
| Version | Description |
|---|---|
| 3.5.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_image_editor_imagick/multi_resize