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

Function Reference/wp get image editor


This function is the main function that you use when you want to get a reference to an image, to edit a local image on the server. It returns a WP_Image_Editor instance and loads a file into it. With that you can manipulate an image by calling methods on it. For more information see: WP_Image_Editor. Keep in mind that the GD library needs to be installed and active on your server to use the full range of the image editor features.


<?php wp_get_image_editor$path$args ); ?> 


(string) (required) Path to file to load. The path parameter should be a local file (such as /var/www/wordpress/some/directory/image). In some cases using a url as the parameter will work, but depending on the server setup and firewalls, fetching the url of the image may or may not work!!
Default: None
(array) (optional) Additional data. Accepts mime_type, methods
Default: Empty


WP_Image_Editor object or WP_Error on failure


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

Change Log

Source File

wp_get_image_editor() is located in wp-includes/media.php