image_resize()重新定义一个图片的大小并保存

目录

描述

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.

image_resize() 描述

用法

<?php image_resize$file$max_w$max_h$crop$suffix$dest_path$jpeg_quality ); ?>

image_resize() 用法

参数

$file

(string) (必填) Image file path.

默认值: None

$max_w

(int) (必填) Maximum width to resize to.

默认值: None

$max_h

(int) (必填) Maximum height to resize to.

默认值: None

$crop

(boolean) (可选) Optional. Whether to crop image or resize.

默认值: false

$suffix

(string) (可选) Optional. File Suffix.

默认值: null

$dest_path

(string) (可选) Optional. New image file path.

默认值: null

$jpeg_quality

(int) (可选) Optional, default is 90. Image quality percentage.

默认值: 90

image_resize() 参数

返回值

(mixed

WP_Error on failure. String with new destination path.

image_resize() 返回值

历史

  • Deprecated: 3.5.0
  • 添加于 版本: 2.5

image_resize() 历史

源文件

image_resize() 函数的代码位于 wp-includes/media.php

image_resize() 源文件