WordPress.org

Ready to get started?Download WordPress

Codex

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

Function Reference/wp get image editor

Description

This function is the main function that you use when you want to edit an image by url. 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 on that you can read: WP_Image_Editor.

Usage

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

Parameters

$path
(string) (required) Path to file to load
Default: None
$args
(array) (optional) Additional data. Accepts mime_type, methods
Default: Empty

Return

(mixed) 
WP_Image_Editor object or WP_Error on failure

Examples

$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

Related