WPDev.one
Core Function
View Source on Trac ↗

image_resize()

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

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

Parameters 3 required

Name / Type Description
$file
string

Image file path.

Required
$max_w
int

Maximum width to resize to.

Required
$max_h
int

Maximum height to resize to.

Required
$crop
bool

Optional. Whether to crop image or resize. Default false.

$suffix
string

Optional. File suffix. Default null.

$dest_path
string

Optional. New image file path. Default null.

$jpeg_quality
int

Optional. Image quality percentage. Default 90.

Return Value

(mixed)
WP_Error on failure. String with new destination path.

Function Information

Since Version
2.5.0
Source File
wp-includes/deprecated.php
Advertisement