
了解数据库技术:SQLite与MySQL的比较
image_resize ( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 )
image_resize: 此函数用于调整图像的大小。
缩小图像以适应一个特定的尺寸,并保存一个新的图像副本。
使用该函数,PNG的透明度将被保留,图像类型也是如此。如果进入的文件是PNG,那么调整后的图像也将是PNG。唯一支持的图像类型是PNG、GIF和JPEG。
有些功能需要API的存在,所以有些PHP版本可能会失去支持: 这不是WordPress的错(功能被降级,而不是实际的缺陷),而是你的PHP版本的问题。
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { _deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' ); $editor = wp_get_image_editor( $file ); if ( is_wp_error( $editor ) ) return $editor; $editor->set_quality( $jpeg_quality ); $resized = $editor->resize( $max_w, $max_h, $crop ); if ( is_wp_error( $resized ) ) return $resized; $dest_file = $editor->generate_filename( $suffix, $dest_path ); $saved = $editor->save( $dest_file ); if ( is_wp_error( $saved ) ) return $saved; return $dest_file; }