image_resize


image_resize ( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 )

Parameters:
  • (string) $file Image file path.
  • (int) $max_w Maximum width to resize to.
  • (int) $max_h Maximum height to resize to.
  • (bool) $crop Optional. Whether to crop image or resize.
  • (string) $suffix Optional. File suffix.
  • (string) $dest_path Optional. New image file path.
  • (int) $jpeg_quality Optional, default is 90. Image quality percentage.
See:
Returns:
  • (mixed) WP_Error on failure. String with new destination path.
Defined at:

Description

Scale down an image to fit a particular size and save a new copy of the image.

The PNG transparency will be preserved using the function, as well as the image type. If the file going in is PNG, then the resized image is going to be PNG. The only supported image types are PNG, GIF, and JPEG.

Some functionality requires API to exist, so some PHP version may lose out support. This is not the fault of WordPress (where functionality is downgraded, not actual defects), but of your PHP version.

Related Functions

add_image_size, has_image_size, image_downsize, get_dirsize, image_resize_dimensions

Top Google Results

User discussions

wpseek mobile