image_make_intermediate_size
函数
image_make_intermediate_size ( $file, $width, $height, $crop = false )
- 参数
-
-
(string)
$file
File path.- Required: 是
-
(int)
$width
Image width.- Required: 是
-
(int)
$height
Image height.- Required: 是
-
(bool)
$crop
Optional. Whether to crop image to specified width and height or resize. Default false.- Required: 否
- Default: false
-
(string)
- 返回值
-
- (array|false) Metadata array on success. False if no image was created.
- 定义位置
-
-
wp-includes/media.php
, line 676
-
wp-includes/media.php
- 引入
- 2.5.0
- 弃用
- –
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.
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; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。