image_make_intermediate_size

The timeline below displays how wordpress function image_make_intermediate_size has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Resizes an image to make a thumbnail or intermediate size.
 *
 * The returned array has the file size, the image width, and image height. The
 * {@see 'image_make_intermediate_size'} filter can be used to hook in and change the
 * values of the returned array. The only parameter is the resized file path.
 *
 * @since 2.5.0
 *
 * @param string     $file   File path.
 * @param int        $width  Image width.
 * @param int        $height Image height.
 * @param bool|array $crop   {
 *     Optional. Image cropping behavior. If false, the image will be scaled (default).
 *     If true, image will be cropped to the specified dimensions using center positions.
 *     If an array, the image will be cropped using the array to specify the crop location:
 *
 *     @type string $0 The x crop position. Accepts 'left' 'center', or 'right'.
 *     @type string $1 The y crop position. Accepts 'top', 'center', or 'bottom'.
 * }
 * @return array|false Metadata array on success. False if no image was created.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}

WordPress Version: 5.4

/**
 * Resizes an image to make a thumbnail or intermediate size.
 *
 * The returned array has the file size, the image width, and image height. The
 * {@see 'image_make_intermediate_size'} filter can be used to hook in and change the
 * values of the returned array. The only parameter is the resized file path.
 *
 * @since 2.5.0
 *
 * @param string $file   File path.
 * @param int    $width  Image width.
 * @param int    $height Image height.
 * @param bool   $crop   Optional. Whether to crop image to specified width and height or resize.
 *                       Default false.
 * @return array|false Metadata array on success. False if no image was created.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}

WordPress Version: 4.6

/**
 * Resizes an image to make a thumbnail or intermediate size.
 *
 * The returned array has the file size, the image width, and image height. The
 * {@see 'image_make_intermediate_size'} filter can be used to hook in and change the
 * values of the returned array. The only parameter is the resized file path.
 *
 * @since 2.5.0
 *
 * @param string $file   File path.
 * @param int    $width  Image width.
 * @param int    $height Image height.
 * @param bool   $crop   Optional. Whether to crop image to specified width and height or resize.
 *                       Default false.
 * @return false|array False, if no image was created. Metadata array on success.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}

WordPress Version: 4.4

/**
 * Resizes 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.
 *
 * @since 2.5.0
 *
 * @param string $file   File path.
 * @param int    $width  Image width.
 * @param int    $height Image height.
 * @param bool   $crop   Optional. Whether to crop image to specified width and height or resize.
 *                       Default false.
 * @return false|array False, if no image was created. Metadata array on success.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}

WordPress Version: 4.3

/**
 * Resizes 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.
 *
 * @since 2.5.0
 *
 * @param string $file   File path.
 * @param int    $width  Image width.
 * @param int    $height Image height.
 * @param bool   $crop   Optional. Whether to crop image to specified height and width or resize.
 *                       Default false.
 * @return false|array False, if no image was created. Metadata array on success.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}

WordPress Version: 4.2

/**
 * Resizes 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.
 *
 * @since 2.5.0
 *
 * @param string $file   File path.
 * @param int    $width  Image width.
 * @param int    $height Image height.
 * @param bool   $crop   Optional. Whether to crop image to specified height and width or resize.
 *                       Default false.
 * @return bool|array False, if no image was created. Metadata array on success.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}

WordPress Version: 3.7

/**
 * 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.
 *
 * @since 2.5.0
 *
 * @param string $file File path.
 * @param int $width Image width.
 * @param int $height Image height.
 * @param bool $crop Optional, default is false. Whether to crop image to specified height and width or resize.
 * @return bool|array False, if no image was created. Metadata array on success.
 */
function image_make_intermediate_size($file, $width, $height, $crop = false)
{
    if ($width || $height) {
        $editor = wp_get_image_editor($file);
        if (is_wp_error($editor) || is_wp_error($editor->resize($width, $height, $crop))) {
            return false;
        }
        $resized_file = $editor->save();
        if (!is_wp_error($resized_file) && $resized_file) {
            unset($resized_file['path']);
            return $resized_file;
        }
    }
    return false;
}