Class Reference/WP Image Editor

来自WordPress中文文档
跳转至: 导航搜索

Description

WP_Image_Editor is a class defined in onlyincludecodewp-includes/class-wp-image-editor.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn that is an abstract class, so it can't be called directly. It is used for implementations like WP_Image_Editor_GD and WP_Image_Editor_Imagick. It has some base functionality that can be used by those implementations.

Interacting with WP_Image_Editor

Usage

$image = wp_get_image_editor( 'cool_image.jpg' ); // Return an implementation that extends <tt>WP_Image_Editor</tt>

if ( ! is_wp_error( $image ) ) {
    $image->rotate( 90 );
    $image->resize( 300, 300, true );
    $image->save( 'new_image.jpg' );
}

Methods and Properties

You shouldn't call an implementation directly. Instead, use wp_get_image_editor(), which looks at which implementation is the best.

Methods

(An ampersand (&) before a method name indicates it returns by reference.)

supports_mime_type( $mime_type )
Checks to see if editor supports the mime-type specified.
save( $destfilename = null, $mime_type = null )
Saves current image to file.
resize( $max_w, $max_h, $crop = false )
Resizes current image.
multi_resize( $sizes );
Processes current image and saves to disk multiple sizes from single source.
crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false )
Crops Image.
rotate( $angle )
Rotates current image counter-clockwise by $angle.
flip( $horz, $vert )
Flips current image on the horizontal or vertical axis.
stream( $mime_type = null )
Streams current image to browser.
get_size()
Gets dimensions of image.
update_size( $width = null, $height = null )
Sets current image size.
set_quality( $quality )
Sets Image Compression quality on a 1-100% scale as an integer (1-100).
get_output_format( $filename = null, $mime_type = null )
Returns preferred mime-type and extension based on provided file's extension and mime, or current file's extension and mime. Will default to `$this->default_mime_type` if requested is not supported. Provides corrected filename only if filename is provided.
generate_filename( $suffix = null, $dest_path = null, $extension = null )
Builds an output filename based on current file, and adding proper suffix
get_suffix()
Builds and returns proper suffix for file based on height and width.
make_image( $filename, $function, $arguments )
Either calls editor's save function or handles file as a stream.
get_mime_type( $extension = null )
Returns first matched mime-type from extension, as mapped from wp_get_mime_types()
get_extension( $mime_type = null )
Returns first matched extension from Mime-type, as mapped from wp_get_mime_types()

Filters

Source File

WP_Image_Editor() is located in onlyincludecodewp-includes/class-wp-image-editor.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.

Resources

Related

Change Log

includeonlydiv style=clear:both; background-color:#EEEEFF; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;This article is marked as in need of editing. You can help Codex by editing it./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude