WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Class Reference/WP Image Editor"

(This example code has nothing to do with the class)
Line 1: Line 1:
===Change Log===
+
==Description==
  +
<tt>WP_Image_Editor</tt> is a class defined in {{Trac|wp-includes/class-wp-image-editor.php}} 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 what can be used by those implementations.
  +
  +
You shouldn't call an implementation directly but use [[Function_Reference/wp_get_image_editor|wp_get_image_editor()]] for that since that method looks which implementation is the best.
  +
  +
==Interacting with WP_Image_Editor==
  +
  +
  +
==Usage==
  +
  +
<pre>
  +
$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' );
  +
}
  +
</pre>
  +
  +
==Methods and Properties==
  +
  +
===Properties===
  +
  +
===Methods===
  +
  +
  +
==Filters==
  +
  +
  +
==Source File==
  +
  +
<tt>WP_Image_Editor()</tt> is located in {{Trac|wp-includes/class-wp-image-editor.php}}.
  +
  +
==Resources==
  +
  +
* [http://make.wordpress.org/core/2012/12/06/wp_image_editor-is-incoming/ WP_Image_Editor is incoming!]
  +
* [http://markoheijnen.com/wordpress-new-image-manipulation/ WordPress new image manipulation]
  +
  +
== Related ==
  +
  +
  +
==Change Log==
 
* Since [[Version_3.5|3.5.0]]
 
* Since [[Version_3.5|3.5.0]]

Revision as of 21:05, 15 December 2012

Description

WP_Image_Editor is a class defined in wp-includes/class-wp-image-editor.php 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 what can be used by those implementations.

You shouldn't call an implementation directly but use wp_get_image_editor() for that since that method looks which implementation is the best.

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

Properties

Methods

Filters

Source File

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

Resources

Related

Change Log