WP_Image_Editor_GD::make_subsize( array $size_data )
Create an image sub-size and return the image meta data value for it.
Description Description
Parameters Parameters
- $size_data
-
(array) (Required) Array of width, height, and whether to crop.
Return Return
(WP_Error|array) WP_Error on error, or the image data array for inclusion in the sizes
array in the image meta.
Source Source
File: wp-includes/class-wp-image-editor-gd.php
public function make_subsize( $size_data ) { if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { return new WP_Error( 'image_subsize_create_error', __( 'Cannot resize the image. Both width and height are not set.' ) ); } $orig_size = $this->size; if ( ! isset( $size_data['width'] ) ) { $size_data['width'] = null; } if ( ! isset( $size_data['height'] ) ) { $size_data['height'] = null; } if ( ! isset( $size_data['crop'] ) ) { $size_data['crop'] = false; } $resized = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); if ( is_wp_error( $resized ) ) { $saved = $resized; } else { $saved = $this->_save( $resized ); imagedestroy( $resized ); } $this->size = $orig_size; if ( ! is_wp_error( $saved ) ) { unset( $saved['path'] ); } return $saved; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
5.3.0 | Introduced. |