Image Editor improvements, see #10528
git-svn-id: http://svn.automattic.com/wordpress/trunk@11965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e1c0fad754
commit
48932f96fe
|
@ -111,7 +111,7 @@ case 'wp-compression-test' :
|
||||||
|
|
||||||
die('0');
|
die('0');
|
||||||
break;
|
break;
|
||||||
case 'load-preview-image' :
|
case 'imgedit-preview' :
|
||||||
$post_id = intval($_GET['postid']);
|
$post_id = intval($_GET['postid']);
|
||||||
if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
|
if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
@ -1348,29 +1348,30 @@ case 'save-widget' :
|
||||||
|
|
||||||
die();
|
die();
|
||||||
break;
|
break;
|
||||||
case 'image-edit-save':
|
case 'image-editor':
|
||||||
// $post_id is the attachment ID
|
$attachment_id = intval($_POST['postid']);
|
||||||
$post_id = intval($_POST['postid']);
|
if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
|
||||||
if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
|
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
check_ajax_referer( "image_editor-$post_id" );
|
check_ajax_referer( "image_editor-$attachment_id" );
|
||||||
|
|
||||||
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
|
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
|
||||||
$msg = wp_save_image($post_id);
|
|
||||||
|
|
||||||
|
$msg = false;
|
||||||
|
switch ( $_POST['do'] ) {
|
||||||
|
case 'save' :
|
||||||
|
$msg = wp_save_image($attachment_id);
|
||||||
|
$msg = json_encode($msg);
|
||||||
die($msg);
|
die($msg);
|
||||||
break;
|
break;
|
||||||
case 'open-image-editor' :
|
case 'scale' :
|
||||||
$post_id = intval($_POST['postid']);
|
$msg = wp_save_image($attachment_id);
|
||||||
if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
|
break;
|
||||||
die('-1');
|
case 'restore' :
|
||||||
|
$msg = wp_restore_image($attachment_id);
|
||||||
check_ajax_referer( "image_editor-$post_id" );
|
break;
|
||||||
|
}
|
||||||
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
|
|
||||||
wp_image_editor($post_id);
|
|
||||||
|
|
||||||
|
wp_image_editor($attachment_id, $msg);
|
||||||
die();
|
die();
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -585,7 +585,8 @@ input.readonly, textarea.readonly {
|
||||||
color: #b6d1e4;
|
color: #b6d1e4;
|
||||||
}
|
}
|
||||||
|
|
||||||
#media-items {
|
#media-items,
|
||||||
|
.imgedit-group {
|
||||||
border-color: #dfdfdf;
|
border-color: #dfdfdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -581,7 +581,8 @@ input.readonly, textarea.readonly {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
#media-items {
|
#media-items,
|
||||||
|
.imgedit-group {
|
||||||
border-color: #dfdfdf;
|
border-color: #dfdfdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 0 0;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.describe-toggle-on,.describe-toggle-off{display:block;line-height:36px;float:right;margin-right:20px;}.describe-toggle-off{display:none;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload .media-upload-form p{margin:0 1em 1em 0;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{padding:5px;width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.5em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:25%;text-align:center;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;border-bottom-style:solid;border-bottom-width:1px;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;border-bottom-color:#DADADA;color:#5A5A5A;}h3.media-title{color:#5A5A5A;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;font-weight:normal;}#gallery-settings .describe td{vertical-align:middle;height:3.5em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;border:1px solid #dfdfdf;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
|
div#media-upload-header{margin:0;padding:0 5px;font-weight:bold;position:relative;border-bottom-width:1px;border-bottom-style:solid;height:2.5em;}body#media-upload ul#sidemenu{font-weight:normal;margin:0 5px;position:absolute;left:0;bottom:-1px;}div#media-upload-error{margin:1em;font-weight:bold;}form{margin:1em;}#search-filter{text-align:right;}th{position:relative;}.media-upload-form label.form-help,td.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}.media-upload-form p.help{margin:0;padding:0;}.media-upload-form fieldset{width:100%;border:none;text-align:justify;margin:0 0 1em 0;padding:0;}.image-align-none-label{background:url(../images/align-none.png) no-repeat center left;}.image-align-left-label{background:url(../images/align-left.png) no-repeat center left;}.image-align-center-label{background:url(../images/align-center.png) no-repeat center left;}.image-align-right-label{background:url(../images/align-right.png) no-repeat center left;}tr.image-size td{width:460px;}tr.image-size div.image-size-item{float:left;width:25%;margin:0;}#library-form .progress,#gallery-form .progress,#flash-upload-ui,.insert-gallery,.describe.startopen,.describe.startclosed{display:none;}.media-item .thumbnail{max-width:128px;max-height:128px;}thead.media-item-info tr{background-color:transparent;}thead.media-item-info th,thead.media-item-info td{border:none;margin:0;}.form-table thead.media-item-info{border:8px solid #fff;}abbr.required{text-decoration:none;border:none;}.describe label{display:inline;}.describe td{vertical-align:middle;padding:0 5px 8px 0;}.describe td.A1{width:132px;}.describe input[type="text"],.describe textarea{width:460px;border-width:1px;border-style:solid;}.describe-toggle-on,.describe-toggle-off{display:block;line-height:36px;float:right;margin-right:20px;}.describe-toggle-off{display:none;}.hidden{height:0;width:0;overflow:hidden;border:none;}#media-upload p.ml-submit{padding:1em 0;}#media-upload p.help,#media-upload label.help{font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif;font-style:italic;font-weight:normal;}#media-upload tr.image-size td.field{text-align:center;}#media-upload #media-items{border-width:1px;border-style:solid;border-bottom:none;width:623px;}#media-upload .media-item{border-bottom-width:1px;border-bottom-style:solid;min-height:36px;width:100%;}#media-upload .ui-sortable .media-item{cursor:move;}.filename{line-height:36px;padding:0 10px;overflow:hidden;}#media-upload .describe{padding:5px;width:100%;clear:both;cursor:default;}#media-upload .slidetoggle{border-top-width:1px;border-top-style:solid;}#media-upload .describe th.label{padding-top:.2em;text-align:left;min-width:120px;}#media-upload tr.align td.field{text-align:center;}#media-upload tr.image-size{margin-bottom:1em;height:3em;}#media-upload #filter{width:623px;}#media-upload #filter .subsubsub{margin:8px 0;}#filter .tablenav select{border-style:solid;border-width:1px;padding:2px;vertical-align:top;width:auto;}#media-upload .del-attachment{display:none;margin:5px 0;}.menu_order{float:right;font-size:11px;margin:10px 10px 0;}.menu_order_input{border:1px solid #ddd;font-size:10px;padding:1px;width:23px;}.ui-sortable-helper{background-color:#fff;border:1px solid #aaa;opacity:.6;filter:alpha(opacity=60);}#media-upload th.order-head{width:25%;text-align:center;}#media-upload .widefat{width:626px;border-style:solid solid none;}.sorthelper{height:37px;width:623px;display:block;}#gallery-settings th.label{width:160px;}#gallery-settings #basic th.label{padding:5px 5px 5px 0;}#gallery-settings .title{clear:both;padding:0 0 3px;border-bottom-style:solid;border-bottom-width:1px;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;border-bottom-color:#DADADA;color:#5A5A5A;}h3.media-title{color:#5A5A5A;font-family:Georgia,"Times New Roman",Times,serif;font-size:1.6em;font-weight:normal;}#gallery-settings .describe td{vertical-align:middle;height:3.5em;}#gallery-settings .describe th.label{padding-top:.5em;text-align:left;}#gallery-settings .describe{padding:5px;width:615px;clear:both;cursor:default;}#gallery-settings .describe select{width:15em;border:1px solid #dfdfdf;}#gallery-settings label,#gallery-settings legend{font-size:13px;color:#464646;margin-right:15px;}#gallery-settings .align .field label{margin:0 1.5em 0 0;}#gallery-settings p.ml-submit{border-top:1px solid #dfdfdf;}#gallery-settings select#columns{width:6em;}#sort-buttons{font-size:.8em;margin:3px 25px -8px 0;text-align:right;max-width:625px;}#sort-buttons a{text-decoration:none;}#sort-buttons #asc,#sort-buttons #showall{padding-left:5px;}#sort-buttons span{margin-right:25px;}
|
|
@ -120,7 +120,7 @@ abbr.required {
|
||||||
|
|
||||||
.describe td {
|
.describe td {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 0 5px 0 0;
|
padding: 0 5px 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.describe td.A1 {
|
.describe td.A1 {
|
||||||
|
@ -155,10 +155,6 @@ abbr.required {
|
||||||
|
|
||||||
/* Specific to Uploader */
|
/* Specific to Uploader */
|
||||||
|
|
||||||
#media-upload .media-upload-form p {
|
|
||||||
margin: 0 1em 1em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#media-upload p.ml-submit {
|
#media-upload p.ml-submit {
|
||||||
padding: 1em 0;
|
padding: 1em 0;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +207,7 @@ abbr.required {
|
||||||
}
|
}
|
||||||
|
|
||||||
#media-upload .describe th.label {
|
#media-upload .describe th.label {
|
||||||
padding-top: .5em;
|
padding-top: .2em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,84 +6,207 @@
|
||||||
* @subpackage Administration
|
* @subpackage Administration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function wp_image_editor($post_id) {
|
function wp_image_editor($post_id, $msg = false) {
|
||||||
$nonce = wp_create_nonce("image_editor-$post_id");
|
$nonce = wp_create_nonce("image_editor-$post_id");
|
||||||
$image_size_opt = "<option value='all'>" . __('all image sizes') . "</option>\n";
|
|
||||||
$image_size_opt .= "<option value='full'>" . __('original image') . "</option>\n";
|
|
||||||
|
|
||||||
$meta = wp_get_attachment_metadata($post_id);
|
$meta = wp_get_attachment_metadata($post_id);
|
||||||
if ( is_array($meta) && is_array($meta['sizes']) ) {
|
$thumb = image_get_intermediate_size($post_id, 'thumbnail');
|
||||||
$sizes = apply_filters('intermediate_image_sizes', array('thumbnail', 'medium', 'large'));
|
$note = '';
|
||||||
$size_names = array(
|
|
||||||
'thumbnail' => __('thumbnail'),
|
|
||||||
'medium' => __('medium'),
|
|
||||||
'large' => __('large')
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ( $sizes as $size ) {
|
if ( is_array($meta) && isset($meta['width']) )
|
||||||
if ( array_key_exists($size, $meta['sizes']) ) {
|
$big = max( $meta['width'], $meta['height'] );
|
||||||
$size_name = isset($size_names[$size]) ? $size_names[$size] : $size;
|
else
|
||||||
$image_size_opt .= "<option value='$size'>$size_name</option>\n";
|
wp_die( __('Image data does not exist. Please re-upload the image.') );
|
||||||
|
|
||||||
|
$sizer = $big > 400 ? 400 / $big : 1;
|
||||||
|
|
||||||
|
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||||
|
$can_restore = !empty($backup_sizes) && isset($backup_sizes['full-orig']);
|
||||||
|
|
||||||
|
|
||||||
|
// temp convert backup sizes
|
||||||
|
if ( isset($meta['sizes']) && is_array($meta['sizes']) ) {
|
||||||
|
$update = false;
|
||||||
|
foreach ( $meta['sizes'] as $name => $val ) {
|
||||||
|
if ( strpos($name, 'backup-') === 0 ) {
|
||||||
|
$m = array();
|
||||||
|
preg_match('/backup-([0-9]+)-(.*)/', $name, $m);
|
||||||
|
if ( !isset($backup_sizes["{$m[2]}-orig"]) )
|
||||||
|
$n = "{$m[2]}-orig";
|
||||||
|
else
|
||||||
|
$n = "{$m[2]}-{$m[1]}";
|
||||||
|
$backup_sizes[$n] = $val;
|
||||||
|
unset($meta['sizes'][$name]);
|
||||||
|
$update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} ?>
|
if ( $update ) {
|
||||||
|
wp_update_attachment_metadata( $post_id, $meta );
|
||||||
|
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// end temp
|
||||||
|
|
||||||
|
|
||||||
|
if ( $msg ) {
|
||||||
|
if ( isset($msg->error) )
|
||||||
|
$note = "<div class='error'><p>$msg->error</p></div>";
|
||||||
|
elseif ( isset($msg->msg) )
|
||||||
|
$note = "<div class='updated'><p>$msg->msg</p></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
<div class="imgedit-wrap">
|
<div class="imgedit-wrap">
|
||||||
<div id="imgedit-panel-<?php echo $post_id; ?>">
|
<?php echo $note; ?>
|
||||||
|
<table id="imgedit-panel-<?php echo $post_id; ?>"><tbody>
|
||||||
|
<tr><td>
|
||||||
<div class="imgedit-menu">
|
<div class="imgedit-menu">
|
||||||
<div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-crop" title="<?php echo esc_attr__( 'Crop' ); ?>"></div><?php
|
<div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php echo esc_attr__( 'Crop' ); ?>"></div><?php
|
||||||
|
|
||||||
if ( function_exists('imagerotate') ) { ?>
|
if ( function_exists('imagerotate') ) { ?>
|
||||||
|
|
||||||
<div onclick="imageEdit.rotate(90, <?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-rleft" title="<?php echo esc_attr__( 'Rotate couter-clockwise' ); ?>"></div>
|
<div onclick="imageEdit.rotate(90, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-rleft" title="<?php echo esc_attr__( 'Rotate couter-clockwise' ); ?>"></div>
|
||||||
<div onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-rright" title="<?php echo esc_attr__( 'Rotate clockwise' ); ?>"></div><?php
|
<div onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-rright" title="<?php echo esc_attr__( 'Rotate clockwise' ); ?>"></div><?php
|
||||||
|
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-fliph" title="<?php echo esc_attr__( 'Flip horizontally' ); ?>"></div>
|
<div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php echo esc_attr__( 'Flip horizontally' ); ?>"></div>
|
||||||
<div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-flipv" title="<?php echo esc_attr__( 'Flip vertically' ); ?>"></div>
|
<div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php echo esc_attr__( 'Flip vertically' ); ?>"></div>
|
||||||
|
|
||||||
<div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-undo disabled" title="<?php echo esc_attr__( 'Undo' ); ?>"></div>
|
<div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php echo esc_attr__( 'Undo' ); ?>"></div>
|
||||||
<div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>)" class="imgedit-redo disabled" title="<?php echo esc_attr__( 'Redo' ); ?>"></div>
|
<div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php echo esc_attr__( 'Redo' ); ?>"></div>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
|
||||||
<span id="imgedit-scale-<?php echo $post_id; ?>">
|
<input type="hidden" id="imgedit-minthumb-<?php echo $post_id; ?>" value="<?php echo ( get_option('thumbnail_size_w') . ':' . get_option('thumbnail_size_h') ); ?>" />
|
||||||
<input type="checkbox" onchange="imageEdit.scaleSwitched(<?php echo $post_id; ?>)" id="imgedit-scale-switch-<?php echo $post_id; ?>" /><label for="imgedit-scale-switch-<?php echo $post_id; ?>">Scale full size image:</label>
|
|
||||||
<span id="imgedit-scale-values-<?php echo $post_id; ?>">
|
|
||||||
<input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleWidthChanged(<?php echo $post_id; ?>)" style="width:4em;" />
|
|
||||||
×
|
|
||||||
<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleHeightChanged(<?php echo $post_id; ?>)" style="width:4em;" />
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
|
<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
|
||||||
<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
|
<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
|
||||||
<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
|
<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
|
||||||
<input type="hidden" id="imgedit-aspect-x-<?php echo $post_id; ?>" value="" />
|
<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo $meta['width']; ?>" />
|
||||||
<input type="hidden" id="imgedit-aspect-y-<?php echo $post_id; ?>" value="" />
|
<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height']; ?>" />
|
||||||
|
|
||||||
<h4><?php _e('Preview Image:'); ?></h4>
|
<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
|
||||||
<div id="imgedit-crop-<?php echo $post_id; ?>" style="position:relative;">
|
<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url('admin-ajax.php'); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand(1, 99999); ?>" />
|
||||||
<img src="<?php echo admin_url('admin-ajax.php') . "?action=load-preview-image&_ajax_nonce={$nonce}&postid={$post_id}&ver=" . rand(1, 99999); ?>" id="image-preview-<?php echo $post_id; ?>" />
|
</div>
|
||||||
|
|
||||||
|
<div class="imgedit-submit">
|
||||||
|
<input type="button" onclick="imageEdit.close(<?php echo "$post_id, '$nonce'"; ?>)" class="button" value="<?php echo esc_attr__( 'Cancel' ); ?>" />
|
||||||
|
<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" class="button-primary imgedit-submit-btn" value="<?php echo esc_attr__( 'Save' ); ?>" />
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="imgedit-settings">
|
||||||
|
<div class="imgedit-group">
|
||||||
|
<div class="imgedit-group-top">
|
||||||
|
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Scale Image'); ?></strong></a>
|
||||||
|
<div class="imgedit-help">
|
||||||
|
<p><?php _e('You can proportionally scale the original image. For best results the scaling should be done before performing any other operations on it like crop, rotate, etc. Note that if you make the image larger it may become fuzzy.'); ?></p>
|
||||||
|
<p><?php printf( __('Original dimensions %s'), $meta['width'] . '×' . $meta['height'] ); ?></p>
|
||||||
|
<div class="imgedit-submit">
|
||||||
|
<span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo $meta['width']; ?>" />×<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo $meta['height']; ?>" />
|
||||||
|
<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span></span>
|
||||||
|
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button-primary" value="<?php echo esc_attr__( 'Scale' ); ?>" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ( $can_restore ) { ?>
|
||||||
|
|
||||||
|
<div class="imgedit-group-top">
|
||||||
|
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Restore Original Image'); ?></strong></a>
|
||||||
|
<div class="imgedit-help">
|
||||||
|
<p><?php _e('Discard any changes and restore the original image. Previously edited copies of the image will not be deleted.'); ?></p>
|
||||||
|
<div class="imgedit-submit">
|
||||||
|
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button-primary" value="<?php echo esc_attr__( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="imgedit-group">
|
||||||
|
<div class="imgedit-group-top">
|
||||||
|
<strong><?php _e('Image Crop'); ?></strong>
|
||||||
|
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
|
||||||
|
<div class="imgedit-help">
|
||||||
|
<p><?php _e('The image can be cropped by clicking on it and dragging to select the desired part. While dragging the dimensions of the selection are displayed below.'); ?></p>
|
||||||
|
<strong><?php _e('Keyboard shortcuts'); ?></strong>
|
||||||
|
<ul>
|
||||||
|
<li><?php _e('Arrow: move by 10px'); ?></li>
|
||||||
|
<li><?php _e('Shift + arrow: move by 1px'); ?></li>
|
||||||
|
<li><?php _e('Ctrl + arrow: resize by 10px'); ?></li>
|
||||||
|
<li><?php _e('Ctrl + Shift + arrow: resize by 1px'); ?></li>
|
||||||
|
<li><?php _e('Shift + drag: lock aspect ratio'); ?></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p><strong><?php _e('Crop Aspect Ratio'); ?></strong><br />
|
||||||
|
<?php _e('You can specify the crop selection aspect ratio then hold down the Shift key while dragging to lock it. The values can be 1:1 (square), 4:3, 16:9, etc. If there is a selection, specifying aspect ratio will set it immediately.'); ?></p>
|
||||||
|
|
||||||
|
<p><strong><?php _e('Crop Selection'); ?></strong><br />
|
||||||
|
<?php _e('Once started, the selection can be adjusted by entering new values (in pixels). Note that these values are scaled to approximately match the original image dimensions. The minimum selection size equals the thumbnail size as set in the Media settings.'); ?></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php _e('Apply to:'); ?>
|
<?php _e('Aspect ratio:'); ?>
|
||||||
<select id="imgedit-save-target-<?php echo $post_id; ?>" onchange="imageEdit.targetChanged(<?php echo $post_id; ?>)">
|
<span class="nowrap">
|
||||||
<?php echo $image_size_opt; ?>
|
<input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" style="width:3em;" />
|
||||||
</select>
|
:
|
||||||
|
<input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" style="width:3em;" />
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p id="imgedit-crop-sel-<?php echo $post_id; ?>">
|
||||||
<input type="button" onclick="imageEdit.close(<?php echo "$post_id, '$nonce'"; ?>)" class="button" value="<?php echo esc_attr__( 'Close' ); ?>" />
|
<?php _e('Selection:'); ?>
|
||||||
<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" class="button-primary" value="<?php echo esc_attr__( 'Save' ); ?>" />
|
<span class="nowrap">
|
||||||
|
<input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" style="width:4em;" />
|
||||||
|
:
|
||||||
|
<input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" style="width:4em;" />
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<script type="text/javascript">imageEdit.targetChanged(<?php echo $post_id; ?>);</script>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if ( $thumb ) {
|
||||||
|
$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="imgedit-group imgedit-applyto">
|
||||||
|
<div class="imgedit-group-top">
|
||||||
|
<strong><?php _e('Thumbnail Settings'); ?></strong>
|
||||||
|
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
|
||||||
|
<p class="imgedit-help"><?php _e('The thumbnail image can be cropped differently. For example it can be square or contain only a portion of the original image to showcase it better. Here you can select whether to apply changes to all image sizes or make the thumbnail different.'); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" /><br /><?php _e('Current thumbnail'); ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p id="imgedit-save-target-<?php echo $post_id; ?>">
|
||||||
|
<strong><?php _e('Apply changes to:'); ?></strong><br />
|
||||||
|
|
||||||
|
<label class="imgedit-label">
|
||||||
|
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
|
||||||
|
<?php _e('All image sizes'); ?></label>
|
||||||
|
|
||||||
|
<label class="imgedit-label">
|
||||||
|
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
|
||||||
|
<?php _e('Thumbnail'); ?></label>
|
||||||
|
|
||||||
|
<label class="imgedit-label">
|
||||||
|
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
|
||||||
|
<?php _e('All sizes except thumbnail'); ?></label>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</td></tr>
|
||||||
|
</tbody></table>
|
||||||
<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
|
<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
|
||||||
|
<script type="text/javascript">imageEdit.init(<?php echo $post_id; ?>);</script>
|
||||||
|
<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e("There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor."); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -109,7 +232,7 @@ function load_image_to_edit($post, $size = 'full') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( is_resource($image) ) {
|
if ( is_resource($image) ) {
|
||||||
$image = apply_filters('load_image_to_edit', $image, $post->ID); // allows plugins to remove a watermark
|
$image = apply_filters('load_image_to_edit', $image, $post->ID);
|
||||||
if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
|
if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
|
||||||
imagealphablending($image, false);
|
imagealphablending($image, false);
|
||||||
imagesavealpha($image, true);
|
imagesavealpha($image, true);
|
||||||
|
@ -268,7 +391,6 @@ function image_edit_apply_changes($img, $changes) {
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function stream_preview_image($post_id) {
|
function stream_preview_image($post_id) {
|
||||||
$post = get_post($post_id);
|
$post = get_post($post_id);
|
||||||
@ini_set('memory_limit', '256M');
|
@ini_set('memory_limit', '256M');
|
||||||
|
@ -297,46 +419,112 @@ function stream_preview_image($post_id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_restore_image($post_id) {
|
||||||
|
$meta = wp_get_attachment_metadata($post_id);
|
||||||
|
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||||
|
$restored = false;
|
||||||
|
$msg = '';
|
||||||
|
|
||||||
|
if ( !is_array($backup_sizes) ) {
|
||||||
|
$msg->error = __('Cannot load image metadata.');
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts = pathinfo($meta['file']);
|
||||||
|
$suffix = time() . rand(100, 999);
|
||||||
|
$default_sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
|
||||||
|
$default_sizes[] = 'full';
|
||||||
|
|
||||||
|
foreach ( $default_sizes as $default_size ) {
|
||||||
|
if ( isset($backup_sizes["$default_size-orig"]) ) {
|
||||||
|
$data = $backup_sizes["$default_size-orig"];
|
||||||
|
if ( 'full' == $default_size ) {
|
||||||
|
$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);
|
||||||
|
|
||||||
|
$meta['file'] = path_join($parts['dirname'], $data['file']);
|
||||||
|
$meta['width'] = $data['width'];
|
||||||
|
$meta['height'] = $data['height'];
|
||||||
|
|
||||||
|
list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
|
||||||
|
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
|
||||||
|
$restored = update_attached_file($post_id, $meta['file']);
|
||||||
|
} else {
|
||||||
|
if ( isset($meta['sizes'][$default_size]) )
|
||||||
|
$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
|
||||||
|
|
||||||
|
$meta['sizes'][$default_size] = $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !wp_update_attachment_metadata($post_id, $meta) || !update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) {
|
||||||
|
$msg->error = __('Cannot save image metadata.');
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$restored )
|
||||||
|
$msg->error = __('Image metadata is inconsistent.');
|
||||||
|
else
|
||||||
|
$msg->msg = __('Image restored successfully.');
|
||||||
|
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
function wp_save_image($post_id) {
|
function wp_save_image($post_id) {
|
||||||
$msg = '';
|
$return = '';
|
||||||
$success = $delete = $full_resized = false;
|
$success = $delete = $scaled = $nocrop = false;
|
||||||
$post = get_post($post_id);
|
$post = get_post($post_id);
|
||||||
@ini_set('memory_limit', '256M');
|
@ini_set('memory_limit', '256M');
|
||||||
$img = load_image_to_edit($post);
|
$img = load_image_to_edit($post);
|
||||||
|
|
||||||
if ( !is_resource($img) )
|
if ( !is_resource($img) ) {
|
||||||
return 'error=' . __('Unable to create new image.');
|
$return->error = esc_js( __('Unable to create new image.') );
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
$fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
|
$fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
|
||||||
$fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
|
$fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
|
||||||
$target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
|
$target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
|
||||||
|
$scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do'];
|
||||||
|
|
||||||
if ( !empty($_REQUEST['history']) ) {
|
if ( $scale && $fwidth > 0 && $fheight > 0 ) {
|
||||||
|
$sX = imagesx($img);
|
||||||
|
$sY = imagesy($img);
|
||||||
|
|
||||||
|
// check if it has roughly the same w / h ratio
|
||||||
|
if ( round($sX / $sY, 2) == round($fwidth / $fheight, 2) ) {
|
||||||
|
// scale the full size image
|
||||||
|
$dst = wp_imagecreatetruecolor($fwidth, $fheight);
|
||||||
|
if ( imagecopyresampled( $dst, $img, 0, 0, 0, 0, $fwidth, $fheight, $sX, $sY ) ) {
|
||||||
|
imagedestroy($img);
|
||||||
|
$img = $dst;
|
||||||
|
$scaled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !$scaled ) {
|
||||||
|
$return->error = esc_js( __('Error while saving the scaled image. Please reload the page and try again.') );
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
} elseif ( !empty($_REQUEST['history']) ) {
|
||||||
$changes = json_decode( stripslashes($_REQUEST['history']) );
|
$changes = json_decode( stripslashes($_REQUEST['history']) );
|
||||||
if ( $changes )
|
if ( $changes )
|
||||||
$img = image_edit_apply_changes($img, $changes);
|
$img = image_edit_apply_changes($img, $changes);
|
||||||
|
} else {
|
||||||
|
$return->error = esc_js( __('Nothing to save, the image has not changed.') );
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $fwidth > 0 && $fheight > 0 ) {
|
$meta = wp_get_attachment_metadata($post_id);
|
||||||
// scale the full size image
|
$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
|
||||||
$dst = wp_imagecreatetruecolor($fwidth, $fheight);
|
|
||||||
if ( imagecopyresampled( $dst, $img, 0, 0, 0, 0, $fwidth, $fheight, imagesx($img), imagesy($img) ) ) {
|
if ( !is_array($meta) ) {
|
||||||
imagedestroy($img);
|
$return->error = esc_js( __('Image data does not exist. Please re-upload the image.') );
|
||||||
$img = $dst;
|
return $return;
|
||||||
$full_resized = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$changes && !$full_resized )
|
if ( !is_array($backup_sizes) )
|
||||||
return 'error=' . __('Nothing to save, the image is not changed.');
|
$backup_sizes = array();
|
||||||
|
|
||||||
$meta = wp_get_attachment_metadata($post_id, false, false);
|
|
||||||
if ( !is_array($meta) )
|
|
||||||
$meta = array();
|
|
||||||
|
|
||||||
if ( !isset($meta['sizes']) || !is_array($meta['sizes']) )
|
|
||||||
$meta['sizes'] = array();
|
|
||||||
|
|
||||||
// generate new filename
|
// generate new filename
|
||||||
$path = get_attached_file($post_id);
|
$path = get_attached_file($post_id);
|
||||||
|
@ -356,11 +544,14 @@ function wp_save_image($post_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the full-size file, also needed to create sub-sizes
|
// save the full-size file, also needed to create sub-sizes
|
||||||
if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) )
|
if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) {
|
||||||
return 'error=' . __('Unable to save the image.');
|
$return->error = esc_js( __('Unable to save the image.') );
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'full' == $target || 'all' == $target || $full_resized ) {
|
if ( 'nothumb' == $target || 'all' == $target || $scaled ) {
|
||||||
$meta['sizes']["backup-{$suffix}-full"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
|
$tag = !isset($backup_sizes['full-orig']) ? 'full-orig' : "full-$suffix";
|
||||||
|
$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
|
||||||
|
|
||||||
$success = update_attached_file($post_id, $new_path);
|
$success = update_attached_file($post_id, $new_path);
|
||||||
$meta['file'] = get_attached_file($post_id, true); // get the path unfiltered
|
$meta['file'] = get_attached_file($post_id, true); // get the path unfiltered
|
||||||
|
@ -370,21 +561,28 @@ function wp_save_image($post_id) {
|
||||||
list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
|
list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
|
||||||
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
|
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
|
||||||
|
|
||||||
if ( $success && $target == 'all' )
|
if ( $success && ('nothumb' == $target || 'all' == $target) ) {
|
||||||
$sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
|
$sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
|
||||||
|
if ( 'nothumb' == $target )
|
||||||
|
$sizes = array_diff( $sizes, array('thumbnail') );
|
||||||
|
}
|
||||||
|
|
||||||
$msg .= "full={$meta['width']}x{$meta['height']}!";
|
$return->fw = $meta['width'];
|
||||||
} elseif ( array_key_exists($target, $meta['sizes']) ) {
|
$return->fh = $meta['height'];
|
||||||
$sizes = array( $target );
|
} elseif ( 'thumbnail' == $target ) {
|
||||||
$success = $delete = true;
|
$sizes = array( 'thumbnail' );
|
||||||
|
$success = $delete = $nocrop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($sizes) ) {
|
if ( isset($sizes) ) {
|
||||||
foreach ( $sizes as $size ) {
|
foreach ( $sizes as $size ) {
|
||||||
if ( isset($meta['sizes'][$size]) )
|
if ( isset($meta['sizes'][$size]) ) {
|
||||||
$meta['sizes']["backup-{$suffix}-$size"] = $meta['sizes'][$size];
|
$tag = !isset($backup_sizes["$size-orig"]) ? "$size-orig" : "$size-$suffix";
|
||||||
|
$backup_sizes[$tag] = $meta['sizes'][$size];
|
||||||
|
}
|
||||||
|
|
||||||
$resized = image_make_intermediate_size($new_path, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
|
$crop = $nocrop ? false : get_option("{$size}_crop");
|
||||||
|
$resized = image_make_intermediate_size($new_path, get_option("{$size}_size_w"), get_option("{$size}_size_h"), $crop );
|
||||||
|
|
||||||
if ( $resized )
|
if ( $resized )
|
||||||
$meta['sizes'][$size] = $resized;
|
$meta['sizes'][$size] = $resized;
|
||||||
|
@ -395,10 +593,13 @@ function wp_save_image($post_id) {
|
||||||
|
|
||||||
if ( $success ) {
|
if ( $success ) {
|
||||||
wp_update_attachment_metadata($post_id, $meta);
|
wp_update_attachment_metadata($post_id, $meta);
|
||||||
|
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
|
||||||
|
|
||||||
if ( $target == 'thumbnail' || $target == 'all' || ( $target == 'full' && !array_key_exists('thumbnail', $meta['sizes']) ) ) {
|
if ( $target == 'thumbnail' || $target == 'all' ) {
|
||||||
if ( $thumb_url = get_attachment_icon_src($post_id) )
|
if ( $thumb = $meta['sizes']['thumbnail'] ) {
|
||||||
$msg .= "thumbnail={$thumb_url[0]}";
|
$file_url = wp_get_attachment_url($post_id);
|
||||||
|
$return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$delete = true;
|
$delete = true;
|
||||||
|
@ -410,6 +611,8 @@ function wp_save_image($post_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
imagedestroy($img);
|
imagedestroy($img);
|
||||||
return $msg;
|
|
||||||
|
$return->msg = esc_js( __('Image saved') );
|
||||||
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||||
$image_edit_button = '';
|
$image_edit_button = '';
|
||||||
if ( gd_edit_image_support($post->post_mime_type) ) {
|
if ( gd_edit_image_support($post->post_mime_type) ) {
|
||||||
$nonce = wp_create_nonce("image_editor-$post->ID");
|
$nonce = wp_create_nonce("image_editor-$post->ID");
|
||||||
$image_edit_button = "<tr><td class='A1B1'><input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open($post->ID, \"$nonce\")' class='button' value='" . esc_attr__( 'Edit image' ) . "' /> <img src='images/wpspin_light.gif' class='imgedit-wait-spin' alt='' /></td></tr>";
|
$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' ) . "' /> <img src='images/wpspin_light.gif' class='imgedit-wait-spin' alt='' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = "
|
$item = "
|
||||||
|
@ -1178,16 +1178,17 @@ function get_media_item( $attachment_id, $args = null ) {
|
||||||
<table class='slidetoggle describe $class'>
|
<table class='slidetoggle describe $class'>
|
||||||
<thead class='media-item-info' id='media-head-$post->ID'>
|
<thead class='media-item-info' id='media-head-$post->ID'>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='A1B1' rowspan='5'><img class='thumbnail' src='$thumb_url' alt='' /></td>
|
<td class='A1B1' id='thumbnail-head-$post->ID' rowspan='5'><img class='thumbnail' src='$thumb_url' alt='' /></td>
|
||||||
<td>$filename</td>
|
<td>$filename</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td>$post->post_mime_type</td></tr>
|
<tr><td>$post->post_mime_type</td></tr>
|
||||||
<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>
|
<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>
|
||||||
<tr><td>" . apply_filters('media_meta', $media_dims, $post) . "</td></tr>
|
<tr><td>" . apply_filters('media_meta', $media_dims, $post) . "</td></tr>
|
||||||
$image_edit_button
|
<tr><td class='A1B1'>$image_edit_button</td></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr><td style='display:none' colspan='2' id='image-editor-$post->ID'></td></tr>\n";
|
<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>
|
||||||
|
<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n";
|
||||||
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'input' => 'text',
|
'input' => 'text',
|
||||||
|
|
|
@ -3,38 +3,50 @@ var imageEdit;
|
||||||
(function($) {
|
(function($) {
|
||||||
imageEdit = {
|
imageEdit = {
|
||||||
iasapi : {},
|
iasapi : {},
|
||||||
|
hold : {},
|
||||||
|
postid : '',
|
||||||
|
|
||||||
intval : function(f) {
|
intval : function(f) {
|
||||||
return f | 0;
|
return f | 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
setState : function(el, s) {
|
setDisabled : function(el, s) {
|
||||||
if ( s )
|
if ( s ) {
|
||||||
el.removeAttr('disabled');
|
|
||||||
else
|
|
||||||
el.attr('disabled', 'disabled');
|
|
||||||
},
|
|
||||||
|
|
||||||
setClass : function(el, c) {
|
|
||||||
if ( c )
|
|
||||||
el.removeClass('disabled');
|
el.removeClass('disabled');
|
||||||
else
|
$('input', el).removeAttr('disabled');
|
||||||
|
} else {
|
||||||
el.addClass('disabled');
|
el.addClass('disabled');
|
||||||
|
$('input', el).attr('disabled', 'disabled');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
gcd : function(a, b) {
|
init : function(postid, nonce) {
|
||||||
var r;
|
var t = this, old = $('#image-editor-' + t.postid),
|
||||||
if ( a == 0 || b == 0 )
|
x = t.intval( $('#imgedit-x-' + postid).val() ),
|
||||||
return 0;
|
y = t.intval( $('#imgedit-y-' + postid).val() );
|
||||||
else if ( a == b )
|
|
||||||
return a;
|
if ( t.postid != postid && old.length )
|
||||||
else {
|
t.close(t.postid);
|
||||||
do {
|
|
||||||
r = a % b;
|
t.hold['w'] = t.hold['ow'] = x;
|
||||||
a = b; b = r;
|
t.hold['h'] = t.hold['oh'] = y;
|
||||||
} while ( r != 0 );
|
t.hold['xy_ratio'] = x / y;
|
||||||
return a;
|
t.hold['sizer'] = parseFloat( $('#imgedit-sizer-' + postid).val() );
|
||||||
|
t.postid = postid;
|
||||||
|
$('#imgedit-response-' + postid).empty();
|
||||||
|
|
||||||
|
$('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) {
|
||||||
|
var k = e.keyCode;
|
||||||
|
|
||||||
|
if ( 36 < k && k < 41 )
|
||||||
|
$(this).blur()
|
||||||
|
|
||||||
|
if ( 13 == k ) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleEditor : function(postid, toggle) {
|
toggleEditor : function(postid, toggle) {
|
||||||
|
@ -43,243 +55,256 @@ imageEdit = {
|
||||||
if ( toggle )
|
if ( toggle )
|
||||||
wait.height( $('#imgedit-panel-' + postid).height() ).fadeIn('fast');
|
wait.height( $('#imgedit-panel-' + postid).height() ).fadeIn('fast');
|
||||||
else
|
else
|
||||||
wait.height(500).fadeOut('fast');
|
wait.fadeOut('fast');
|
||||||
},
|
},
|
||||||
|
|
||||||
isChecked : function(chkbox) {
|
toggleHelp : function(el) {
|
||||||
return ( !chkbox.attr('disabled') && chkbox[0].checked );
|
$(el).siblings('.imgedit-help').slideToggle('fast');
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAspect : function(postid) {
|
getTarget : function(postid) {
|
||||||
var enable = this.isChecked( $('#imgedit-scale-switch-' + postid) ), X, Y;
|
return $('input:checked', '#imgedit-save-target-' + postid).val() || 'all';
|
||||||
|
},
|
||||||
|
|
||||||
if ( enable ) {
|
scaleChanged : function(postid, x) {
|
||||||
X = this.intval( $('#imgedit-aspect-x-' + postid).val() );
|
var w = $('#imgedit-scale-width-' + postid), h = $('#imgedit-scale-height-' + postid),
|
||||||
Y = this.intval( $('#imgedit-aspect-y-' + postid).val() );
|
warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = '';
|
||||||
return X / Y;
|
|
||||||
|
if ( x ) {
|
||||||
|
h1 = (w.val() != '') ? this.intval( w.val() / this.hold['xy_ratio'] ) : '';
|
||||||
|
h.val( h1 );
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
w1 = (h.val() != '') ? this.intval( h.val() * this.hold['xy_ratio'] ) : '';
|
||||||
|
w.val( w1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ( h1 && h1 > this.hold['oh'] ) || ( w1 && w1 > this.hold['ow'] ) )
|
||||||
|
warn.css('visibility', 'visible');
|
||||||
|
else
|
||||||
|
warn.css('visibility', 'hidden');
|
||||||
},
|
},
|
||||||
|
|
||||||
scaleWidthChanged : function(postid) {
|
getSelRatio : function(postid) {
|
||||||
var src = $('#imgedit-scale-width-' + postid), aspect;
|
var x = this.hold['w'], y = this.hold['h'],
|
||||||
|
X = this.intval( $('#imgedit-crop-width-' + postid).val() ),
|
||||||
|
Y = this.intval( $('#imgedit-crop-height-' + postid).val() );
|
||||||
|
|
||||||
if ( !src.attr('disabled') ) {
|
if ( X && Y )
|
||||||
aspect = this.getAspect(postid);
|
return X + ':' + Y;
|
||||||
|
|
||||||
if ( aspect != 0 )
|
if ( x && y )
|
||||||
$('#imgedit-scale-height-' + postid).val( (src.val() != '') ? this.intval( src.val() / aspect ) : '' );
|
return x + ':' + y;
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
scaleHeightChanged : function(postid) {
|
return '1:1';
|
||||||
var src = $('#imgedit-scale-height-' + postid), aspect;
|
|
||||||
if ( !src.attr('disabled') ) {
|
|
||||||
aspect = this.getAspect(postid);
|
|
||||||
if ( aspect != 0 )
|
|
||||||
$('#imgedit-scale-width-' + postid).val( (src.val() != '') ? this.intval(src.val() * aspect) : '' );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
setDefaultAspect : function(postid) {
|
|
||||||
var t = this, g, host = $('#image-preview-' + postid),
|
|
||||||
X = host.attr('width'), Y = host.attr('height');
|
|
||||||
|
|
||||||
while( (g = t.gcd(X, Y) ) > 1) {
|
|
||||||
X = t.intval( Math.ceil(X / g) );
|
|
||||||
Y = t.intval( Math.ceil(Y / g) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( X > 10 && Y > 10 ) {
|
|
||||||
while ( X > 10 && Y > 10 ) {
|
|
||||||
X = t.intval( Math.ceil(X / 10) );
|
|
||||||
Y = t.intval( Math.ceil(Y / 10) );
|
|
||||||
}
|
|
||||||
while( ( g = t.gcd(X, Y) ) > 1) {
|
|
||||||
X = t.intval( Math.ceil(X / g) );
|
|
||||||
Y = t.intval( Math.ceil(Y / g) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('#imgedit-aspect-x-' + postid).val(X);
|
|
||||||
$('#imgedit-aspect-y-' + postid).val(Y);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
filterHistory : function(postid) {
|
filterHistory : function(postid) {
|
||||||
// apply undo state to history
|
// apply undo state to history
|
||||||
var history = $('#imgedit-history-' + postid).val(), pop;
|
var history = $('#imgedit-history-' + postid).val(), pop, n, o, i, op = [];
|
||||||
|
|
||||||
if ( history != '' ) {
|
if ( history != '' ) {
|
||||||
|
history = JSON.parse(history);
|
||||||
pop = this.intval( $('#imgedit-undone-' + postid).val() );
|
pop = this.intval( $('#imgedit-undone-' + postid).val() );
|
||||||
if ( pop > 0 ) {
|
if ( pop > 0 ) {
|
||||||
history = JSON.parse(history);
|
|
||||||
while ( pop > 0 ) {
|
while ( pop > 0 ) {
|
||||||
history.pop();
|
history.pop();
|
||||||
pop--;
|
pop--;
|
||||||
}
|
}
|
||||||
history = JSON.stringify(history);
|
}
|
||||||
|
|
||||||
|
if ( !history.length ) {
|
||||||
|
this.newDims(postid, this.hold['ow'], this.hold['oh']);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore
|
||||||
|
o = history[history.length - 1];
|
||||||
|
if ( o.hasOwnProperty('c') ) {
|
||||||
|
this.newDims(postid, o.c.fw, o.c.fh);
|
||||||
|
} else if ( o.hasOwnProperty('r') ) {
|
||||||
|
this.newDims(postid, o.r.fw, o.r.fh);
|
||||||
|
} else if ( o.hasOwnProperty('f') ) {
|
||||||
|
this.newDims(postid, o.f.fw, o.f.fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter the values
|
||||||
|
for ( n in history ) {
|
||||||
|
i = history[n];
|
||||||
|
if ( i.hasOwnProperty('c') ) {
|
||||||
|
op[n] = { 'c': { 'x': i.c.x, 'y': i.c.y, 'w': i.c.w, 'h': i.c.h } };
|
||||||
|
} else if ( i.hasOwnProperty('r') ) {
|
||||||
|
op[n] = { 'r': i.r.r };
|
||||||
|
} else if ( i.hasOwnProperty('f') ) {
|
||||||
|
op[n] = { 'f': i.f.f };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return history;
|
return JSON.stringify(op);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshEditor : function(postid, nonce, callback) {
|
refreshEditor : function(postid, nonce, callback) {
|
||||||
var t = this, data, host;
|
var t = this, data, img;
|
||||||
|
|
||||||
t.toggleEditor(postid, 1);
|
t.toggleEditor(postid, 1);
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'action': 'load-preview-image',
|
'action': 'imgedit-preview',
|
||||||
'_ajax_nonce': nonce,
|
'_ajax_nonce': nonce,
|
||||||
'postid': postid,
|
'postid': postid,
|
||||||
'history': t.filterHistory(postid),
|
'history': t.filterHistory(postid),
|
||||||
'rand': t.intval(Math.random() * 1000000)
|
'rand': t.intval(Math.random() * 1000000)
|
||||||
};
|
};
|
||||||
|
|
||||||
host = $('<img id="image-preview-' + postid + '" />');
|
img = $('<img id="image-preview-' + postid + '" />');
|
||||||
host.load( function() {
|
img.load( function() {
|
||||||
var parent = $('#imgedit-crop-' + postid);
|
var parent = $('#imgedit-crop-' + postid), t = imageEdit;
|
||||||
|
|
||||||
parent.empty().append(host);
|
parent.empty().append(img);
|
||||||
t.initCrop(postid, host, parent);
|
t.initCrop(postid, img, parent);
|
||||||
$('#imgedit-panel-' + postid).show();
|
t.setCropSelection(postid, 0);
|
||||||
|
|
||||||
if ( (typeof callback != "unknown") && callback != null )
|
if ( (typeof callback != "unknown") && callback != null )
|
||||||
callback();
|
callback();
|
||||||
|
|
||||||
t.toggleEditor(postid, 0);
|
t.toggleEditor(postid, 0);
|
||||||
|
|
||||||
}).attr('src', ajaxurl + '?' + $.param(data));
|
}).attr('src', ajaxurl + '?' + $.param(data));
|
||||||
},
|
},
|
||||||
|
|
||||||
save : function(postid, nonce) {
|
action : function(postid, nonce, action) {
|
||||||
var t = this, fwidth = -1, fheight = -1, w, h, data,
|
var t = this, data, w, h, fw, fh;
|
||||||
scaled = t.isChecked( $('#imgedit-scale-switch-' + postid) ),
|
|
||||||
target = $('#imgedit-save-target-' + postid).val();
|
|
||||||
|
|
||||||
if ( scaled ) {
|
if ( t.notsaved(postid) )
|
||||||
w = $('#imgedit-scale-width-' + postid);
|
return false;
|
||||||
h = $('#imgedit-scale-height-' + postid);
|
|
||||||
fwidth = t.intval(w.val());
|
|
||||||
fheight = t.intval(h.val());
|
|
||||||
|
|
||||||
if ( fwidth <= 0 ) {
|
data = {
|
||||||
|
'action': 'image-editor',
|
||||||
|
'_ajax_nonce': nonce,
|
||||||
|
'postid': postid
|
||||||
|
};
|
||||||
|
|
||||||
|
if ( 'scale' == action ) {
|
||||||
|
w = $('#imgedit-scale-width-' + postid),
|
||||||
|
h = $('#imgedit-scale-height-' + postid),
|
||||||
|
fw = t.intval(w.val()),
|
||||||
|
fh = t.intval(h.val());
|
||||||
|
|
||||||
|
if ( fw < 1 ) {
|
||||||
w.focus();
|
w.focus();
|
||||||
return;
|
return false;;
|
||||||
} else if ( fheight <= 0 ) {
|
} else if ( fh < 1 ) {
|
||||||
h.focus();
|
h.focus();
|
||||||
return;
|
return false;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( fw == t.hold.ow || fh == t.hold.oh )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
data['do'] = 'scale';
|
||||||
|
data['fwidth'] = fw;
|
||||||
|
data['fheight'] = fh;
|
||||||
|
} else if ( 'restore' == action ) {
|
||||||
|
data['do'] = 'restore';
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
t.toggleEditor(postid, 1);
|
t.toggleEditor(postid, 1);
|
||||||
|
|
||||||
data = {
|
|
||||||
'action': 'image-edit-save',
|
|
||||||
'_ajax_nonce': nonce,
|
|
||||||
'postid': postid,
|
|
||||||
'history': t.filterHistory(postid),
|
|
||||||
'target': target,
|
|
||||||
'fwidth': fwidth,
|
|
||||||
'fheight': fheight
|
|
||||||
};
|
|
||||||
|
|
||||||
$.post(ajaxurl, data, function(r) {
|
$.post(ajaxurl, data, function(r) {
|
||||||
var fields = r.split('!'), pair, res, fw, fh, i, thumbnail;
|
$('#image-editor-' + postid).empty().append(r);
|
||||||
|
|
||||||
for ( i = 0; i < fields.length; i++ ) {
|
|
||||||
pair = fields[i].split('=');
|
|
||||||
if ( pair.length == 2 ) {
|
|
||||||
switch ( pair[0] ) {
|
|
||||||
case 'full':
|
|
||||||
// update full size dimensions
|
|
||||||
res = pair[1].split('x');
|
|
||||||
if ( res.length == 2 ) {
|
|
||||||
fw = res[0];
|
|
||||||
fh = res[1];
|
|
||||||
$('#image-dims-' + postid).html( fw + ' × ' + fh );
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear undo history, it's no longer valid since we changed the original full size image
|
|
||||||
$('#imgedit-history-' + postid).val('');
|
|
||||||
$('#imgedit-undone-' + postid).val(0);
|
|
||||||
t.setClass($('#image-undo-' + postid), false);
|
|
||||||
t.setClass($('#image-redo-' + postid), false);
|
|
||||||
break;
|
|
||||||
case 'thumbnail':
|
|
||||||
// force a reload of the thumbnail ??
|
|
||||||
thumbnail = $('#media-item-' + postid);
|
|
||||||
if ( thumbnail.length == 0 ) {
|
|
||||||
// when the flash uploader is employed media items are named 'media-item-SWFUpload_n_n' with n >= 0
|
|
||||||
// we therefore try to locate a known element and navigate up to the image-item-info div object
|
|
||||||
thumbnail = $('#media-dims-' + postid).closest('.media-item-info');
|
|
||||||
}
|
|
||||||
thumbnail = thumbnail.find('.thumbnail');
|
|
||||||
thumbnail.attr('src', pair[1]);
|
|
||||||
break;
|
|
||||||
case 'error':
|
|
||||||
$('#imgedit-panel-' + postid).html(pair[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.toggleEditor(postid, 0);
|
t.toggleEditor(postid, 0);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
save : function(postid, nonce) {
|
||||||
|
var data, target = this.getTarget(postid), history = this.filterHistory(postid);
|
||||||
|
|
||||||
|
if ( '' == history )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this.toggleEditor(postid, 1);
|
||||||
|
data = {
|
||||||
|
'action': 'image-editor',
|
||||||
|
'_ajax_nonce': nonce,
|
||||||
|
'postid': postid,
|
||||||
|
'history': history,
|
||||||
|
'target': target,
|
||||||
|
'do': 'save'
|
||||||
|
};
|
||||||
|
|
||||||
|
$.post(ajaxurl, data, function(r) {
|
||||||
|
var ret = JSON.parse(r);
|
||||||
|
|
||||||
|
if ( ret.error ) {
|
||||||
|
$('#imgedit-response-' + postid).html('<div class="error"><p>' + ret.error + '</p><div>');
|
||||||
|
imageEdit.close(postid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ret.fw && ret.fh )
|
||||||
|
$('#media-dims-' + postid).html( ret.fw + ' × ' + ret.fh );
|
||||||
|
|
||||||
|
if ( ret.thumbnail )
|
||||||
|
$('.thumbnail', '#thumbnail-head-' + postid).attr('src', ''+ret.thumbnail);
|
||||||
|
|
||||||
|
if ( ret.msg )
|
||||||
|
$('#imgedit-response-' + postid).html('<div class="updated"><p>' + ret.msg + '</p></div>');
|
||||||
|
|
||||||
|
imageEdit.close(postid);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
open : function(postid, nonce) {
|
open : function(postid, nonce) {
|
||||||
var t = this, data, elem = $('#image-editor-' + postid), head = $('#media-head-' + postid),
|
var data, elem = $('#image-editor-' + postid), head = $('#media-head-' + postid),
|
||||||
btn = $('#imgedit-open-btn-' + postid), spin = btn.siblings('img');
|
btn = $('#imgedit-open-btn-' + postid), spin = btn.siblings('img');
|
||||||
|
|
||||||
btn.attr('disabled', 'disabled');
|
btn.attr('disabled', 'disabled');
|
||||||
spin.css('visibility', 'visible');
|
spin.css('visibility', 'visible');
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'action': 'open-image-editor',
|
'action': 'image-editor',
|
||||||
'_ajax_nonce': nonce,
|
'_ajax_nonce': nonce,
|
||||||
'postid': postid
|
'postid': postid,
|
||||||
|
'do': 'open'
|
||||||
};
|
};
|
||||||
|
|
||||||
elem.load(ajaxurl, data, function() {
|
elem.load(ajaxurl, data, function() {
|
||||||
|
|
||||||
elem.fadeIn('fast');
|
elem.fadeIn('fast');
|
||||||
|
|
||||||
head.fadeOut('fast', function(){
|
head.fadeOut('fast', function(){
|
||||||
btn.removeAttr('disabled');
|
btn.removeAttr('disabled');
|
||||||
spin.css('visibility', 'hidden');
|
spin.css('visibility', 'hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
t.toggleEditor(postid, 1);
|
|
||||||
|
|
||||||
$('#image-preview-' + postid).load(function(){
|
|
||||||
var t = imageEdit, parent = $('#imgedit-crop-' + postid);
|
|
||||||
|
|
||||||
t.initCrop(postid, this, parent);
|
|
||||||
t.setDefaultAspect(postid);
|
|
||||||
t.toggleEditor(postid, 0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
imgLoaded : function(postid) {
|
||||||
|
var img = $('#image-preview-' + postid), parent = $('#imgedit-crop-' + postid);
|
||||||
|
|
||||||
|
this.initCrop(postid, img, parent);
|
||||||
|
this.setCropSelection(postid, 0);
|
||||||
|
this.toggleEditor(postid, 0);
|
||||||
|
},
|
||||||
|
|
||||||
initCrop : function(postid, image, parent) {
|
initCrop : function(postid, image, parent) {
|
||||||
var t = this;
|
var t = this, selW = $('#imgedit-sel-width-' + postid),
|
||||||
|
selH = $('#imgedit-sel-height-' + postid);
|
||||||
|
|
||||||
t.iasapi = $(image).imgAreaSelect({
|
t.iasapi = $(image).imgAreaSelect({
|
||||||
parent: parent,
|
parent: parent,
|
||||||
instance: true,
|
instance: true,
|
||||||
handles: true,
|
handles: true,
|
||||||
keys: true,
|
keys: true,
|
||||||
minHeight: 5,
|
minWidth: 3,
|
||||||
minWidth: 5,
|
minHeight: 3,
|
||||||
|
|
||||||
onInit: function(img, c) {
|
onInit: function(img, c) {
|
||||||
parent.children().mousedown(function(e){
|
parent.children().mousedown(function(e){
|
||||||
var sel, ratio = false, X = t.intval( $('#imgedit-aspect-x-' + postid).val() ),
|
var ratio = false, sel, defRatio;
|
||||||
Y = t.intval( $('#imgedit-aspect-y-' + postid).val() );
|
|
||||||
|
|
||||||
defRatio = ( X && Y ) ? X + ':' + Y : '1:1';
|
|
||||||
|
|
||||||
if ( e.shiftKey ) {
|
if ( e.shiftKey ) {
|
||||||
sel = t.iasapi.getSelection();
|
sel = t.iasapi.getSelection();
|
||||||
ratio = ( sel.width && sel.height ) ? sel.width + ':' + sel.height : defRatio;
|
defRatio = t.getSelRatio(postid);
|
||||||
|
ratio = ( sel && sel.width && sel.height ) ? sel.width + ':' + sel.height : defRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
t.iasapi.setOptions({
|
t.iasapi.setOptions({
|
||||||
|
@ -288,19 +313,73 @@ imageEdit = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSelectStart: function(img, c) {
|
||||||
|
imageEdit.setDisabled($('#imgedit-crop-sel-' + postid), 1);
|
||||||
|
},
|
||||||
|
|
||||||
onSelectEnd: function(img, c) {
|
onSelectEnd: function(img, c) {
|
||||||
var sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height };
|
imageEdit.setCropSelection(postid, c);
|
||||||
$('#imgedit-selection-' + postid).val( JSON.stringify(sel) );
|
},
|
||||||
|
|
||||||
|
onSelectChange: function(img, c) {
|
||||||
|
var sizer = imageEdit.hold.sizer;
|
||||||
|
selW.val( imageEdit.round(c.width / sizer) );
|
||||||
|
selH.val( imageEdit.round(c.height / sizer) );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setCropSelection : function(postid, c) {
|
||||||
|
var sel, min = $('#imgedit-minthumb-' + postid).val() || '128:128',
|
||||||
|
sizer = this.hold['sizer'];
|
||||||
|
min = min.split(':');
|
||||||
|
c = c || 0;
|
||||||
|
|
||||||
|
if ( !c || ( c.width < 3 && c.height < 3 ) ) {
|
||||||
|
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
|
||||||
|
this.setDisabled($('#imgedit-crop-sel-' + postid), 0);
|
||||||
|
$('#imgedit-sel-width-' + postid).val('');
|
||||||
|
$('#imgedit-sel-height-' + postid).val('');
|
||||||
|
$('#imgedit-selection-' + postid).val('');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( c.width < (min[0] * sizer) && c.height < (min[1] * sizer) ) {
|
||||||
|
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 0);
|
||||||
|
$('#imgedit-selection-' + postid).val('');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height };
|
||||||
|
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 1);
|
||||||
|
$('#imgedit-selection-' + postid).val( JSON.stringify(sel) );
|
||||||
|
},
|
||||||
|
|
||||||
close : function(postid) {
|
close : function(postid) {
|
||||||
|
if ( this.notsaved(postid) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this.iasapi = {};
|
||||||
|
this.hold = {};
|
||||||
$('#image-editor-' + postid).fadeOut('fast', function() {
|
$('#image-editor-' + postid).fadeOut('fast', function() {
|
||||||
$('#media-head-' + postid).fadeIn('fast');
|
$('#media-head-' + postid).fadeIn('fast');
|
||||||
|
$(this).empty();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
notsaved : function(postid) {
|
||||||
|
var h = $('#imgedit-history-' + postid).val(),
|
||||||
|
history = (h != '') ? JSON.parse(h) : new Array(),
|
||||||
|
pop = this.intval( $('#imgedit-undone-' + postid).val() );
|
||||||
|
|
||||||
|
if ( pop < history.length ) {
|
||||||
|
if ( confirm( $('#imgedit-leaving-' + postid).html() ) )
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
addStep : function(op, postid, nonce) {
|
addStep : function(op, postid, nonce) {
|
||||||
var t = this, elem = $('#imgedit-history-' + postid),
|
var t = this, elem = $('#imgedit-history-' + postid),
|
||||||
history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array(),
|
history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array(),
|
||||||
|
@ -317,25 +396,46 @@ imageEdit = {
|
||||||
elem.val( JSON.stringify(history) );
|
elem.val( JSON.stringify(history) );
|
||||||
|
|
||||||
t.refreshEditor(postid, nonce, function() {
|
t.refreshEditor(postid, nonce, function() {
|
||||||
t.setClass($('#image-undo-' + postid), true);
|
t.setDisabled($('#image-undo-' + postid), true);
|
||||||
t.setClass($('#image-redo-' + postid), false);
|
t.setDisabled($('#image-redo-' + postid), false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
rotate : function(angle, postid, nonce) {
|
rotate : function(angle, postid, nonce, t) {
|
||||||
this.addStep({ 'r': angle }, postid, nonce);
|
if ( $(t).hasClass('disabled') )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this.addStep({ 'r': { 'r': angle, 'fw': this.hold['h'], 'fh': this.hold['w'] }}, postid, nonce);
|
||||||
},
|
},
|
||||||
|
|
||||||
flip : function (axis, postid, nonce) {
|
flip : function (axis, postid, nonce, t) {
|
||||||
this.addStep({ 'f': axis }, postid, nonce);
|
if ( $(t).hasClass('disabled') )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this.addStep({ 'f': { 'f': axis, 'fw': this.hold['w'], 'fh': this.hold['h'] }}, postid, nonce);
|
||||||
},
|
},
|
||||||
|
|
||||||
crop : function (postid, nonce) {
|
// w, h are the new full size dims
|
||||||
|
newDims : function(postid, w, h) {
|
||||||
|
var max = Math.max( w, h ), s;
|
||||||
|
|
||||||
|
s = max > 400 ? 400 / max : 1;
|
||||||
|
this.hold['sizer'] = s;
|
||||||
|
this.hold['w'] = w;
|
||||||
|
this.hold['h'] = h;
|
||||||
|
return s;
|
||||||
|
},
|
||||||
|
|
||||||
|
crop : function (postid, nonce, t) {
|
||||||
var sel = $('#imgedit-selection-' + postid).val();
|
var sel = $('#imgedit-selection-' + postid).val();
|
||||||
|
|
||||||
if ( sel != '' ) {
|
if ( $(t).hasClass('disabled') || sel == '' )
|
||||||
|
return false;
|
||||||
|
|
||||||
sel = JSON.parse(sel);
|
sel = JSON.parse(sel);
|
||||||
if ( sel.w > 0 && sel.h > 0 )
|
if ( sel.w > 0 && sel.h > 0 ) {
|
||||||
|
sel['fw'] = this.intval( $('#imgedit-sel-width-' + postid).val() );
|
||||||
|
sel['fh'] = this.intval( $('#imgedit-sel-height-' + postid).val() );
|
||||||
this.addStep({ 'c': sel }, postid, nonce);
|
this.addStep({ 'c': sel }, postid, nonce);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -352,8 +452,8 @@ imageEdit = {
|
||||||
var elem = $('#imgedit-history-' + postid),
|
var elem = $('#imgedit-history-' + postid),
|
||||||
history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array();
|
history = (elem.val() != '') ? JSON.parse(elem.val()) : new Array();
|
||||||
|
|
||||||
t.setClass($('#image-redo-' + postid), true);
|
t.setDisabled($('#image-redo-' + postid), true);
|
||||||
t.setClass(button, pop < history.length);
|
t.setDisabled(button, pop < history.length);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -366,27 +466,98 @@ imageEdit = {
|
||||||
|
|
||||||
elem.val(pop);
|
elem.val(pop);
|
||||||
t.refreshEditor(postid, nonce, function() {
|
t.refreshEditor(postid, nonce, function() {
|
||||||
t.setClass($('#image-undo-' + postid), true);
|
t.setDisabled($('#image-undo-' + postid), true);
|
||||||
t.setClass(button, pop > 0);
|
t.setDisabled(button, pop > 0);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
scaleSwitched : function(postid) {
|
setNumSelection : function(postid) {
|
||||||
var enable = this.isChecked( $('#imgedit-scale-switch-' + postid) );
|
var sel, elX = $('#imgedit-sel-width-' + postid), elY = $('#imgedit-sel-height-' + postid),
|
||||||
|
x = this.intval( elX.val() ), y = this.intval( elY.val() ),
|
||||||
|
img = $('#image-preview-' + postid), imgh = img.height(), imgw = img.width(),
|
||||||
|
sizer = this.hold['sizer'], x1, y1, x2, y2, ias = this.iasapi;
|
||||||
|
|
||||||
this.setState($('#imgedit-scale-width-' + postid), enable);
|
if ( x < 1 ) {
|
||||||
this.setState($('#imgedit-scale-height-' + postid), enable);
|
elX.val('');
|
||||||
// this.setClass($('#imgedit-scale-values-' + postid), !enable);
|
return false;
|
||||||
this.scaleWidthChanged(postid);
|
}
|
||||||
|
|
||||||
|
if ( y < 1 ) {
|
||||||
|
elY.val('');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( x && y && ( sel = ias.getSelection() ) ) {
|
||||||
|
x2 = sel.x1 + Math.round( x * sizer );
|
||||||
|
y2 = sel.y1 + Math.round( y * sizer );
|
||||||
|
x1 = sel.x1;
|
||||||
|
y1 = sel.y1;
|
||||||
|
|
||||||
|
if ( x2 > imgw ) {
|
||||||
|
x1 = 0;
|
||||||
|
x2 = imgw;
|
||||||
|
elX.val( Math.round( x2 / sizer ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( y2 > imgh ) {
|
||||||
|
y1 = 0;
|
||||||
|
y2 = imgh;
|
||||||
|
elY.val( Math.round( y2 / sizer ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
ias.setSelection( x1, y1, x2, y2 );
|
||||||
|
ias.update();
|
||||||
|
this.setCropSelection(postid, ias.getSelection());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
targetChanged : function(postid) {
|
round : function(num) {
|
||||||
var target = $('#imgedit-save-target-' + postid).val(),
|
var s;
|
||||||
enable = (target == 'full' || target == 'all');
|
num = Math.round(num);
|
||||||
|
|
||||||
this.setState($('#imgedit-scale-switch-' + postid), enable);
|
if ( this.hold.sizer > 0.6 )
|
||||||
this.setClass($('#imgedit-scale-' + postid), !enable);
|
return num;
|
||||||
this.scaleSwitched(postid);
|
|
||||||
|
s = num.toString().slice(-1);
|
||||||
|
|
||||||
|
if ( '1' == s )
|
||||||
|
return num - 1;
|
||||||
|
else if ( '9' == s )
|
||||||
|
return num + 1;
|
||||||
|
|
||||||
|
return num;
|
||||||
|
},
|
||||||
|
|
||||||
|
setRatioSelection : function(postid, n, el) {
|
||||||
|
var sel, r, x = this.intval( $('#imgedit-crop-width-' + postid).val() ),
|
||||||
|
y = this.intval( $('#imgedit-crop-height-' + postid).val() ),
|
||||||
|
h = $('#image-preview-' + postid).height();
|
||||||
|
|
||||||
|
if ( !this.intval( $(el).val() ) ) {
|
||||||
|
$(el).val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( x && y ) {
|
||||||
|
this.iasapi.setOptions({
|
||||||
|
aspectRatio: x + ':' + y
|
||||||
|
});
|
||||||
|
|
||||||
|
if ( sel = this.iasapi.getSelection(true) ) {
|
||||||
|
r = Math.ceil( sel.y1 + ((sel.x2 - sel.x1) / (x / y)) );
|
||||||
|
|
||||||
|
if ( r > h ) {
|
||||||
|
r = h;
|
||||||
|
if ( n )
|
||||||
|
$('#imgedit-crop-height-' + postid).val('');
|
||||||
|
else
|
||||||
|
$('#imgedit-crop-width-' + postid).val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.iasapi.setSelection( sel.x1, sel.y1, sel.x2, r );
|
||||||
|
this.iasapi.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1292,8 +1292,7 @@ strong .post-com-count {
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-table td,
|
.form-table td {
|
||||||
#wpbody-content .describe td {
|
|
||||||
margin-bottom: 9px;
|
margin-bottom: 9px;
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
@ -1306,8 +1305,7 @@ strong .post-com-count {
|
||||||
text-shadow: rgba(255,255,255,1) 0 1px 0;
|
text-shadow: rgba(255,255,255,1) 0 1px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-table th,
|
.form-table th {
|
||||||
#wpbody-content .describe th {
|
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
@ -2834,6 +2832,13 @@ table .inline-edit-row fieldset ul.cat-hover {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#wpbody-content .describe th {
|
||||||
|
vertical-align: top;
|
||||||
|
text-align: left;
|
||||||
|
padding: 10px;
|
||||||
|
width: 140px;
|
||||||
|
}
|
||||||
|
|
||||||
#wpbody-content .describe .media-item-info tr {
|
#wpbody-content .describe .media-item-info tr {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
@ -2842,8 +2847,8 @@ table .inline-edit-row fieldset ul.cat-hover {
|
||||||
padding: 4px 10px 0;
|
padding: 4px 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wpbody-content .describe .media-item-info .A1B1 {
|
.describe .media-item-info .A1B1 {
|
||||||
padding-bottom: 8px;
|
padding: 0 15px 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wpbody-content .filename {
|
#wpbody-content .filename {
|
||||||
|
@ -2917,6 +2922,11 @@ abbr.required {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#wpbody-content .media-single .media-item {
|
||||||
|
border-bottom-style: none;
|
||||||
|
border-bottom-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
#wpbody-content #media-items {
|
#wpbody-content #media-items {
|
||||||
border-style: solid solid none;
|
border-style: solid solid none;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
|
@ -3343,15 +3353,41 @@ label,
|
||||||
top: -3px;
|
top: -3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.describe .image-editor {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
.imgedit-wrap {
|
.imgedit-wrap {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 500px;
|
}
|
||||||
|
|
||||||
|
.imgedit-settings p {
|
||||||
|
margin: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.describe .imgedit-wrap table td {
|
||||||
|
vertical-align: top;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-wrap p,
|
||||||
|
.describe .imgedit-wrap table td {
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.describe .imgedit-wrap table td.imgedit-settings {
|
||||||
|
padding: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.imgedit-settings input {
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.imgedit-wait {
|
.imgedit-wait {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
background: #FFFFFF url(images/wpspin_light.gif) no-repeat scroll 200px 75px;
|
background: #FFFFFF url(images/wpspin_light.gif) no-repeat scroll 22px 10px;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
filter: alpha(opacity=70);
|
filter: alpha(opacity=70);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -3359,7 +3395,8 @@ label,
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-disabled {
|
.media-disabled,
|
||||||
|
.imgedit-settings .disabled {
|
||||||
color: grey;
|
color: grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3370,7 +3407,8 @@ label,
|
||||||
}
|
}
|
||||||
|
|
||||||
.imgedit-menu {
|
.imgedit-menu {
|
||||||
margin: 5px 0;
|
margin: 0 0 12px;
|
||||||
|
min-width: 315px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.imgedit-menu div {
|
.imgedit-menu div {
|
||||||
|
@ -3385,6 +3423,10 @@ label,
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.imgedit-crop-wrap {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
.imgedit-crop {
|
.imgedit-crop {
|
||||||
background: transparent url(images/imgedit.gif) no-repeat scroll -62px 2px;
|
background: transparent url(images/imgedit.gif) no-repeat scroll -62px 2px;
|
||||||
margin: 0 8px 0 0;
|
margin: 0 8px 0 0;
|
||||||
|
@ -3421,3 +3463,71 @@ label,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.imgedit-applyto img {
|
||||||
|
margin: 0 8px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-group-top {
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-applyto .imgedit-label {
|
||||||
|
padding: 2px 0 0;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-help {
|
||||||
|
display: none;
|
||||||
|
font-style: italic;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-help ul li {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.imgedit-help-toggle {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#wpbody-content .imgedit-response div {
|
||||||
|
width: 600px;
|
||||||
|
margin: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-table td.imgedit-response {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-submit {
|
||||||
|
margin: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-submit-btn {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-wrap .nowrap {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.imgedit-scale-warn {
|
||||||
|
color: red;
|
||||||
|
font-size: 20px;
|
||||||
|
font-style: normal;
|
||||||
|
visibility: hidden;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imgedit-group {
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
-moz-border-radius: 8px;
|
||||||
|
-khtml-border-radius: 8px;
|
||||||
|
-webkit-border-radius: 8px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
padding: 2px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2575,7 +2575,8 @@ function wp_delete_attachment($post_id) {
|
||||||
delete_post_meta($post_id, '_wp_trash_meta_status');
|
delete_post_meta($post_id, '_wp_trash_meta_status');
|
||||||
delete_post_meta($post_id, '_wp_trash_meta_time');
|
delete_post_meta($post_id, '_wp_trash_meta_time');
|
||||||
|
|
||||||
$meta = wp_get_attachment_metadata( $post_id, false, false );
|
$meta = wp_get_attachment_metadata( $post_id );
|
||||||
|
$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
|
||||||
$file = get_attached_file( $post_id );
|
$file = get_attached_file( $post_id );
|
||||||
|
|
||||||
do_action('delete_attachment', $post_id);
|
do_action('delete_attachment', $post_id);
|
||||||
|
@ -2609,16 +2610,13 @@ function wp_delete_attachment($post_id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset($meta['sizes']) && is_array($meta['sizes']) ) {
|
if ( is_array($backup_sizes) ) {
|
||||||
foreach ( array_keys($meta['sizes']) as $size ) {
|
foreach ( $backup_sizes as $size ) {
|
||||||
if ( preg_match('/backup-[0-9]+/', $size) ) { // make sure this is a backup
|
$del_file = path_join( dirname($meta['file']), $size['file'] );
|
||||||
if ( $del = image_get_intermediate_size($post_id, $size) ) {
|
$del_file = apply_filters('wp_delete_file', $del_file);
|
||||||
$del_file = apply_filters('wp_delete_file', $del['path']);
|
|
||||||
@ unlink( path_join($uploadpath['basedir'], $del_file) );
|
@ unlink( path_join($uploadpath['basedir'], $del_file) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = apply_filters('wp_delete_file', $file);
|
$file = apply_filters('wp_delete_file', $file);
|
||||||
|
|
||||||
|
@ -2639,21 +2637,13 @@ function wp_delete_attachment($post_id) {
|
||||||
* @param bool $unfiltered Optional, default is false. If true, filters are not run.
|
* @param bool $unfiltered Optional, default is false. If true, filters are not run.
|
||||||
* @return string|bool Attachment meta field. False on failure.
|
* @return string|bool Attachment meta field. False on failure.
|
||||||
*/
|
*/
|
||||||
function wp_get_attachment_metadata( $post_id, $unfiltered = false, $remove_backups = true ) {
|
function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
if ( !$post =& get_post( $post_id ) )
|
if ( !$post =& get_post( $post_id ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
|
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
|
||||||
|
|
||||||
if ( $remove_backups && isset($data['sizes']) && is_array($data['sizes']) ) {
|
|
||||||
$sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
|
|
||||||
foreach ( $data['sizes'] as $size => $val ) {
|
|
||||||
if ( !in_array( $size, $sizes, true ) )
|
|
||||||
unset($data['sizes'][$size]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $unfiltered )
|
if ( $unfiltered )
|
||||||
return $data;
|
return $data;
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
$scripts->add( 'codepress', '/wp-includes/js/codepress/codepress.js', false, '0.9.6' );
|
$scripts->add( 'codepress', '/wp-includes/js/codepress/codepress.js', false, '0.9.6' );
|
||||||
$scripts->add_data( 'codepress', 'group', 1 );
|
$scripts->add_data( 'codepress', 'group', 1 );
|
||||||
|
|
||||||
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), '20090831' );
|
$scripts->add( 'image-edit', "/wp-admin/js/image-edit$suffix.js", array('jquery', 'json2', 'imgareaselect'), '20090922' );
|
||||||
$scripts->add_data( 'image-edit', 'group', 1 );
|
$scripts->add_data( 'image-edit', 'group', 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,12 +442,12 @@ function wp_default_styles( &$styles ) {
|
||||||
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' );
|
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' );
|
||||||
|
|
||||||
// all colors stylesheets need to have the same query strings (cache manifest compat)
|
// all colors stylesheets need to have the same query strings (cache manifest compat)
|
||||||
$colors_version = '20090824';
|
$colors_version = '20090922';
|
||||||
|
|
||||||
$styles->add( 'wp-admin', "/wp-admin/wp-admin$suffix.css", array(), '20090824' );
|
$styles->add( 'wp-admin', "/wp-admin/wp-admin$suffix.css", array(), '20090824' );
|
||||||
$styles->add_data( 'wp-admin', 'rtl', "/wp-admin/rtl$suffix.css" );
|
$styles->add_data( 'wp-admin', 'rtl', "/wp-admin/rtl$suffix.css" );
|
||||||
|
|
||||||
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090824' );
|
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090922' );
|
||||||
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
$styles->add_data( 'ie', 'conditional', 'lte IE 7' );
|
||||||
|
|
||||||
// Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
|
// Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
|
||||||
|
@ -460,7 +460,7 @@ function wp_default_styles( &$styles ) {
|
||||||
$styles->add_data( 'colors-classic', 'rtl', true );
|
$styles->add_data( 'colors-classic', 'rtl', true );
|
||||||
|
|
||||||
$styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20090630' );
|
$styles->add( 'global', "/wp-admin/css/global$suffix.css", array(), '20090630' );
|
||||||
$styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20090612' );
|
$styles->add( 'media', "/wp-admin/css/media$suffix.css", array(), '20090922' );
|
||||||
$styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20090603' );
|
$styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css", array(), '20090603' );
|
||||||
$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20090514' );
|
$styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css", array(), '20090514' );
|
||||||
$styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20090514' );
|
$styles->add( 'install', "/wp-admin/css/install$suffix.css", array(), '20090514' );
|
||||||
|
|
Loading…
Reference in New Issue