image_make_intermediate_size

Definition:
function image_make_intermediate_size($file, $width, $height, $crop=false) {}

Resize an image to make a thumbnail or intermediate size.
The returned array has the file size, the image width, and image height. The filter ‘image_make_intermediate_size’ can be used to hook in and change the values of the returned array. The only parameter is the resized file path.

Parameters

  • string $file: File path.
  • int $width: Image width.
  • int $height: Image height.
  • bool $crop: Optional, default is false. Whether to crop image to specified height and width or resize.

Return values

returns:False, if no image was created. Metadata array on success.

Defined filters

  • image_make_intermediate_size
    apply_filters('image_make_intermediate_size', $resized_file)

Source code

function image_make_intermediate_size($file, $width, $height, $crop=false) {

	if ( $width || $height ) {

		$resized_file = image_resize($file, $width, $height, $crop);

		if ( !is_wp_error($resized_file) && $resized_file && $info = getimagesize($resized_file) ) {

			$resized_file = apply_filters('image_make_intermediate_size', $resized_file);

			return array(

				'file' => wp_basename( $resized_file ),

				'width' => $info[0],

				'height' => $info[1],

			);

		}

	}

	return false;

}

1995

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: