GC_Image_Editor_GD::multi_resize()

最后更新于:2021-11-27 23:38:55

GC_Image_Editor_GD::multi_resize( array$sizes)

Create multiple smaller images from a single source.

参数

$sizes

(array) (Required) An array of image size data arrays. Either a height or width must be provided. If one of the two is set to null, the resize will maintain aspect ratio according to the source image.

  • ‘size’
    (array) Array of height, width values, and whether to crop.
    • ‘width’
      (int) Image width. Optional if $height is specified.
    • ‘height’
      (int) Image height. Optional if $width is specified.
    • ‘crop’
      (bool) Optional. Whether to crop the image. Default false.

响应

(array) An array of resized images’ metadata by size.

源文件

文件: gc-includes/class-gc-image-editor-gd.php

	public function multi_resize( $sizes ) {
		$metadata = array();

		foreach ( $sizes as $size => $size_data ) {
			$meta = $this->make_subsize( $size_data );

			if ( ! is_gc_error( $meta ) ) {
				$metadata[ $size ] = $meta;
			}
		}

		return $metadata;
	}