Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Hotfixing bug in wp_save_image() in WordPress 3.5
<?php
add_action( 'wp_ajax_image-editor', 'fix_wp_ajax_image_editor', 0 );
function fix_wp_ajax_image_editor() {
$attachment_id = intval( $_POST['postid'] );
if ( empty( $attachment_id ) || ! current_user_can( 'edit_post', $attachment_id ) )
wp_die( -1 );
check_ajax_referer( "image_editor-$attachment_id" );
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
$msg = false;
switch ( $_POST['do'] ) {
case 'save' :
$old_meta = wp_get_attachment_metadata( $attachment_id );
$msg = wp_save_image( $attachment_id );
$msg = json_encode( $msg );
break;
case 'scale' :
$old_meta = wp_get_attachment_metadata( $attachment_id );
$msg = wp_save_image( $attachment_id );
break;
case 'restore' :
$msg = wp_restore_image( $attachment_id );
break;
}
if( isset( $old_meta ) ) {
$new_meta = wp_get_attachment_metadata( $attachment_id );
$new_meta['sizes'] = array_merge( $old_meta['sizes'], $new_meta['sizes'] );
wp_update_attachment_metadata( $attachment_id, $new_meta );
if( 'save' == $_POST['do'] )
wp_die( $msg );
}
wp_image_editor( $attachment_id, $msg );
wp_die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.