WP_Image_Editor: the last stand.

* Have wp_get_image_editor() rather than WP_Image_Editor::get_instance(). Having static factory methods would be less confusing if there weren't also static methods tied to individual editor implementations.
 * Lazy-load the WP_Image_Editor base class and editor implementations.
 * Have WP_Image_Editor_GD::supports_mime_type() actually check which types it supports.
 * Deprecate gd_edit_image_support() in favor of wp_image_editor_supports().

props DH-Shredder, scribu, markoheijnen. fixes #22356. see #6821.



git-svn-id: https://develop.svn.wordpress.org/trunk@22817 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2012-11-22 09:52:16 +00:00
parent ff6ae18d2d
commit f44d1d009e
9 changed files with 216 additions and 170 deletions
+2 -2
View File
@@ -457,7 +457,7 @@ function stream_preview_image( $post_id ) {
$post = get_post( $post_id );
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
$img = WP_Image_Editor::get_instance( _load_image_to_edit_path( $post_id ) );
$img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );
if ( is_wp_error( $img ) )
return false;
@@ -566,7 +566,7 @@ function wp_save_image( $post_id ) {
$success = $delete = $scaled = $nocrop = false;
$post = get_post( $post_id );
$img = WP_Image_Editor::get_instance( _load_image_to_edit_path( $post_id, 'full' ) );
$img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
if ( is_wp_error( $img ) ) {
$return->error = esc_js( __('Unable to create new image.') );
return $return;
+2 -2
View File
@@ -36,7 +36,7 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
}
}
$editor = WP_Image_Editor::get_instance( $src );
$editor = wp_get_image_editor( $src );
if ( is_wp_error( $editor ) )
return $editor;
@@ -100,7 +100,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
if ( $sizes ) {
$editor = WP_Image_Editor::get_instance( $file );
$editor = wp_get_image_editor( $file );
if ( ! is_wp_error( $editor ) )
$metadata['sizes'] = $editor->multi_resize( $sizes );
+2 -2
View File
@@ -1122,7 +1122,7 @@ function get_media_item( $attachment_id, $args = null ) {
$media_dims = apply_filters( 'media_meta', $media_dims, $post );
$image_edit_button = '';
if ( gd_edit_image_support( $post->post_mime_type ) ) {
if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
$nonce = wp_create_nonce( "image_editor-$post->ID" );
$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
}
@@ -2253,7 +2253,7 @@ function edit_form_image_editor() {
$att_url = wp_get_attachment_url( $post->ID );
$image_edit_button = '';
if ( gd_edit_image_support( $post->post_mime_type ) ) {
if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) {
$nonce = wp_create_nonce( "image_editor-$post->ID" );
$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>";
}