wp_get_image_editor()
wp_get_image_editor( string $path, array $args = array(…
wp_get_image_editor( string $path, array $args = array() )
返回WP_Image_编辑器实例并将文件加载到其中。
Returns a WP_Image_Editor instance and loads file into it.
目录锚点:#参数#源码#笔记
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $path | (string) | 要加载的文件的路径。 |
| $args | (array) | 用于检索图像编辑器的其他参数。 |
源码(Source)
/**
* Returns a WP_Image_Editor instance and loads file into it.
*
* @since 3.5.0
*
* @param string $path Path to the file to load.
* @param array $args Optional. Additional arguments for retrieving the image editor.
* Default empty array.
* @return WP_Image_Editor|WP_Error The WP_Image_Editor object if successful, an WP_Error
* object otherwise.
*/
function wp_get_image_editor( $path, $args = array() ) {
$args['path'] = $path;
if ( ! isset( $args['mime_type'] ) ) {
$file_info = wp_check_filetype( $args['path'] );
// If $file_info['type'] is false, then we let the editor attempt to
// figure out the file type, rather than forcing a failure based on extension.
if ( isset( $file_info ) && $file_info['type'] )
$args['mime_type'] = $file_info['type'];
}
$implementation = _wp_image_editor_choose( $args );
if ( $implementation ) {
$editor = new $implementation( $path );
$loaded = $editor->load();
if ( is_wp_error( $loaded ) )
return $loaded;
return $editor;
}
return new WP_Error( 'image_no_editor', __('No editor could be selected.') );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.5.0 | wp-includes/media.php | 10 | 18 |
笔记(Notes)
基本示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。



还没有任何评论,赶紧来占个楼吧!