<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23095] trunk: Add the ability to click &quot;Edit&quot; and kick out to the advanced image editor from within the Media modal.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23095">23095</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2012-12-06 05:52:19 +0000 (Thu, 06 Dec 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add the ability to click &quot;Edit&quot; and kick out to the advanced image editor from within the Media modal. New window, with &quot;Refresh&quot; offered on your return. fixes <a href="http://core.trac.wordpress.org/ticket/22743">#22743</a>. props koopersmith, nacin, helenyhou.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadminincludesimageeditphp">trunk/wp-admin/includes/image-edit.php</a></li>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpincludescssmediaviewscss">trunk/wp-includes/css/media-views.css</a></li>
<li><a href="#trunkwpincludesjsmediaviewsjs">trunk/wp-includes/js/media-views.js</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (23094 => 23095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2012-12-06 05:34:17 UTC (rev 23094)
+++ trunk/wp-admin/css/wp-admin.css        2012-12-06 05:52:19 UTC (rev 23095)
</span><span class="lines">@@ -4150,23 +4150,26 @@
</span><span class="cx">         margin: 8px 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.post-php .imgedit-wrap table {
+        width: 100%;
+}
+
</ins><span class="cx"> .describe .imgedit-wrap table td,
</span><span class="cx"> .wp_attachment_holder .imgedit-wrap table td {
</span><span class="cx">         vertical-align: top;
</span><span class="cx">         padding-top: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.imgedit-wrap p,
-.describe .imgedit-wrap table td {
-        font-size: 11px;
-        line-height: 18px;
-}
-
</del><span class="cx"> .describe .imgedit-wrap table td.imgedit-settings {
</span><span class="cx">         padding: 0 5px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.wp_attachment_holder .imgedit-wrap table td.imgedit-settings {
+        width: 250px;
+}
+
</ins><span class="cx"> td.imgedit-settings input {
</span><ins>+        margin-top: 0;
</ins><span class="cx">         vertical-align: middle;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -4349,19 +4352,10 @@
</span><span class="cx">         margin-bottom: 8px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.imgedit-help ul li {
-        font-size: 11px;
-}
-
</del><span class="cx"> a.imgedit-help-toggle {
</span><span class="cx">         text-decoration: none;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#wpbody-content .imgedit-response div {
-        width: 600px;
-        margin: 8px;
-}
-
</del><span class="cx"> .form-table td.imgedit-response {
</span><span class="cx">         padding: 0;
</span><span class="cx"> }
</span><span class="lines">@@ -4389,8 +4383,8 @@
</span><span class="cx"> .imgedit-group {
</span><span class="cx">         border-width: 1px;
</span><span class="cx">         border-style: solid;
</span><del>-        -webkit-border-radius: 8px;
-        border-radius: 8px;
</del><ins>+        -webkit-border-radius: 3px;
+        border-radius: 3px;
</ins><span class="cx">         margin-bottom: 8px;
</span><span class="cx">         padding: 2px 10px;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesimageeditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/image-edit.php (23094 => 23095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/image-edit.php        2012-12-06 05:34:17 UTC (rev 23094)
+++ trunk/wp-admin/includes/image-edit.php        2012-12-06 05:52:19 UTC (rev 23095)
</span><span class="lines">@@ -191,7 +191,7 @@
</span><span class="cx">         &lt;/td&gt;&lt;/tr&gt;
</span><span class="cx">         &lt;/tbody&gt;&lt;/table&gt;
</span><span class="cx">         &lt;div class=&quot;imgedit-wait&quot; id=&quot;imgedit-wait-&lt;?php echo $post_id; ?&gt;&quot;&gt;&lt;/div&gt;
</span><del>-        &lt;script type=&quot;text/javascript&quot;&gt;imageEdit.init(&lt;?php echo $post_id; ?&gt;);&lt;/script&gt;
</del><ins>+        &lt;script type=&quot;text/javascript&quot;&gt;jQuery( function() { imageEdit.init(&lt;?php echo $post_id; ?&gt;); });&lt;/script&gt;
</ins><span class="cx">         &lt;div class=&quot;hidden&quot; id=&quot;imgedit-leaving-&lt;?php echo $post_id; ?&gt;&quot;&gt;&lt;?php _e(&quot;There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor.&quot;); ?&gt;&lt;/div&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> &lt;?php
</span></span></pre></div>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (23094 => 23095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2012-12-06 05:34:17 UTC (rev 23094)
+++ trunk/wp-admin/includes/media.php        2012-12-06 05:52:19 UTC (rev 23095)
</span><span class="lines">@@ -2270,20 +2270,18 @@
</span><span class="cx"> function edit_form_image_editor() {
</span><span class="cx">         $post = get_post();
</span><span class="cx"> 
</span><ins>+        $open = isset( $_GET['image-editor'] );
+        if ( $open )
+                require_once ABSPATH . 'wp-admin/includes/image-edit.php';
+
</ins><span class="cx">         $thumb_url = false;
</span><span class="cx">         if ( $attachment_id = intval( $post-&gt;ID ) )
</span><del>-                $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 600 ), true );
</del><ins>+                $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true );
</ins><span class="cx"> 
</span><span class="cx">         $filename = esc_html( basename( $post-&gt;guid ) );
</span><span class="cx">         $title = esc_attr( $post-&gt;post_title );
</span><span class="cx">         $alt_text = get_post_meta( $post-&gt;ID, '_wp_attachment_image_alt', true );
</span><span class="cx"> 
</span><del>-        $media_dims = '';
-        $meta = wp_get_attachment_metadata( $post-&gt;ID );
-        if ( is_array( $meta ) &amp;&amp; array_key_exists( 'width', $meta ) &amp;&amp; array_key_exists( 'height', $meta ) )
-                $media_dims .= &quot;&lt;span id='media-dims-$post-&gt;ID'&gt;{$meta['width']}&amp;nbsp;&amp;times;&amp;nbsp;{$meta['height']}&lt;/span&gt; &quot;;
-        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
-
</del><span class="cx">         $att_url = wp_get_attachment_url( $post-&gt;ID );
</span><span class="cx"> 
</span><span class="cx">         if ( wp_attachment_is_image( $post-&gt;ID ) ) :
</span><span class="lines">@@ -2296,11 +2294,13 @@
</span><span class="cx">         &lt;div class=&quot;wp_attachment_holder&quot;&gt;
</span><span class="cx">                 &lt;div class=&quot;imgedit-response&quot; id=&quot;imgedit-response-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> 
</span><del>-                &lt;div class=&quot;wp_attachment_image&quot; id=&quot;media-head-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;
</del><ins>+                &lt;div&lt;?php if ( $open ) echo ' style=&quot;display:none&quot;'; ?&gt; class=&quot;wp_attachment_image&quot; id=&quot;media-head-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;
</ins><span class="cx">                         &lt;p id=&quot;thumbnail-head-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;&lt;img class=&quot;thumbnail&quot; src=&quot;&lt;?php echo set_url_scheme( $thumb_url[0] ); ?&gt;&quot; style=&quot;max-width:100%&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</span><span class="cx">                         &lt;p&gt;&lt;?php echo $image_edit_button; ?&gt;&lt;/p&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><del>-                &lt;div style=&quot;display:none&quot; class=&quot;image-editor&quot; id=&quot;image-editor-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;&lt;/div&gt;
</del><ins>+                &lt;div&lt;?php if ( ! $open ) echo ' style=&quot;display:none&quot;'; ?&gt; class=&quot;image-editor&quot; id=&quot;image-editor-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;
+                        &lt;?php if ( $open ) wp_image_editor( $attachment_id ); ?&gt;
+                &lt;/div&gt;
</ins><span class="cx">         &lt;/div&gt;
</span><span class="cx">         &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludescssmediaviewscss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/media-views.css (23094 => 23095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/media-views.css        2012-12-06 05:34:17 UTC (rev 23094)
+++ trunk/wp-includes/css/media-views.css        2012-12-06 05:52:19 UTC (rev 23095)
</span><span class="lines">@@ -1308,6 +1308,7 @@
</span><span class="cx">         float: left;
</span><span class="cx">         max-width: 120px;
</span><span class="cx">         max-height: 120px;
</span><ins>+        margin-top: 5px;
</ins><span class="cx">         margin-right: 10px;
</span><span class="cx">         margin-bottom: 5px;
</span><span class="cx"> }
</span><span class="lines">@@ -1347,19 +1348,32 @@
</span><span class="cx">         max-width: 100%;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.attachment-info .delete-attachment a {
-        color: red;
-        padding: 2px 4px;
-        margin: -2px -4px;
</del><ins>+.attachment-info .edit-attachment,
+.attachment-info .refresh-attachment,
+.attachment-info .delete-attachment {
+        display: block;
</ins><span class="cx">         text-decoration: none;
</span><span class="cx">         white-space: nowrap;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.attachment-info .delete-attachment a:hover {
-        color: #fff;
-        background: red;
</del><ins>+.attachment-info .refresh-attachment,
+.attachment-details.needs-refresh .attachment-info .edit-attachment {
+        display: none;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.attachment-details.needs-refresh .attachment-info .refresh-attachment,
+.attachment-info .edit-attachment {
+        display: block;
+}
+
+.attachment-info .delete-attachment {
+        color: #bc0b0b;
+}
+
+.attachment-info .delete-attachment:hover {
+        color: red;
+}
+
</ins><span class="cx"> /**
</span><span class="cx">  * Attachment Display Settings
</span><span class="cx">  */
</span></span></pre></div>
<a id="trunkwpincludesjsmediaviewsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-views.js (23094 => 23095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-views.js        2012-12-06 05:34:17 UTC (rev 23094)
+++ trunk/wp-includes/js/media-views.js        2012-12-06 05:52:19 UTC (rev 23095)
</span><span class="lines">@@ -4021,7 +4021,9 @@
</span><span class="cx">                         'change [data-setting] input':    'updateSetting',
</span><span class="cx">                         'change [data-setting] select':   'updateSetting',
</span><span class="cx">                         'change [data-setting] textarea': 'updateSetting',
</span><del>-                        'click .delete-attachment':       'deleteAttachment'
</del><ins>+                        'click .delete-attachment':       'deleteAttachment',
+                        'click .edit-attachment':         'editAttachment',
+                        'click .refresh-attachment':      'refreshAttachment'
</ins><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 initialize: function() {
</span><span class="lines">@@ -4038,11 +4040,21 @@
</span><span class="cx">                         return this;
</span><span class="cx">                 },
</span><span class="cx"> 
</span><del>-                deleteAttachment: function(event) {
</del><ins>+                deleteAttachment: function( event ) {
</ins><span class="cx">                         event.preventDefault();
</span><span class="cx"> 
</span><span class="cx">                         if ( confirm( l10n.warnDelete ) )
</span><span class="cx">                                 this.model.destroy();
</span><ins>+                },
+
+                editAttachment: function( event ) {
+                        this.$el.addClass('needs-refresh');
+                },
+
+                refreshAttachment: function( event ) {
+                        this.$el.removeClass('needs-refresh');
+                        event.preventDefault();
+                        this.model.fetch();
</ins><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (23094 => 23095)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2012-12-06 05:34:17 UTC (rev 23094)
+++ trunk/wp-includes/media.php        2012-12-06 05:52:19 UTC (rev 23095)
</span><span class="lines">@@ -1337,10 +1337,13 @@
</span><span class="cx">                         'update' =&gt; false,
</span><span class="cx">                         'delete' =&gt; false,
</span><span class="cx">                 ),
</span><ins>+                'editLink'   =&gt; false,
</ins><span class="cx">         );
</span><span class="cx"> 
</span><del>-        if ( current_user_can( 'edit_post', $attachment-&gt;ID ) )
</del><ins>+        if ( current_user_can( 'edit_post', $attachment-&gt;ID ) ) {
</ins><span class="cx">                 $response['nonces']['update'] = wp_create_nonce( 'update-post_' . $attachment-&gt;ID );
</span><ins>+                $response['editLink'] = get_edit_post_link( $attachment-&gt;ID, 'raw' );
+        }
</ins><span class="cx"> 
</span><span class="cx">         if ( current_user_can( 'delete_post', $attachment-&gt;ID ) )
</span><span class="cx">                 $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment-&gt;ID );
</span><span class="lines">@@ -1703,14 +1706,22 @@
</span><span class="cx">                         &lt;div class=&quot;details&quot;&gt;
</span><span class="cx">                                 &lt;div class=&quot;filename&quot;&gt;{{ data.filename }}&lt;/div&gt;
</span><span class="cx">                                 &lt;div class=&quot;uploaded&quot;&gt;{{ data.dateFormatted }}&lt;/div&gt;
</span><del>-                                &lt;# if ( 'image' === data.type &amp;&amp; ! data.uploading &amp;&amp; data.width &amp;&amp; data.height ) { #&gt;
-                                        &lt;div class=&quot;dimensions&quot;&gt;{{ data.width }} &amp;times; {{ data.height }}&lt;/div&gt;
</del><ins>+
+                                &lt;# if ( 'image' === data.type &amp;&amp; ! data.uploading ) { #&gt;
+                                        &lt;# if ( data.width &amp;&amp; data.height ) { #&gt;
+                                                &lt;div class=&quot;dimensions&quot;&gt;{{ data.width }} &amp;times; {{ data.height }}&lt;/div&gt;
+                                        &lt;# } #&gt;
+
+                                        &lt;# if ( data.can.save ) { #&gt;
+                                                &lt;a class=&quot;edit-attachment&quot; href=&quot;{{ data.editLink }}&amp;amp;image-editor&quot; target=&quot;_blank&quot;&gt;&lt;?php _e( 'Edit Image' ); ?&gt;&lt;/a&gt;
+                                                &lt;a class=&quot;refresh-attachment&quot; href=&quot;#&quot;&gt;&lt;?php _e( 'Refresh' ); ?&gt;&lt;/a&gt;
+                                        &lt;# } #&gt;
</ins><span class="cx">                                 &lt;# } #&gt;
</span><ins>+
</ins><span class="cx">                                 &lt;# if ( ! data.uploading &amp;&amp; data.can.remove ) { #&gt;
</span><del>-                                        &lt;div class=&quot;delete-attachment&quot;&gt;
-                                                &lt;a href=&quot;#&quot;&gt;&lt;?php _e( 'Delete Permanently' ); ?&gt;&lt;/a&gt;
-                                        &lt;/div&gt;
</del><ins>+                                        &lt;a class=&quot;delete-attachment&quot; href=&quot;#&quot;&gt;&lt;?php _e( 'Delete Permanently' ); ?&gt;&lt;/a&gt;
</ins><span class="cx">                                 &lt;# } #&gt;
</span><ins>+
</ins><span class="cx">                                 &lt;div class=&quot;compat-meta&quot;&gt;
</span><span class="cx">                                         &lt;# if ( data.compat &amp;&amp; data.compat.meta ) { #&gt;
</span><span class="cx">                                                 {{{ data.compat.meta }}}
</span></span></pre>
</div>
</div>

</body>
</html>