Skip to content

Commit

Permalink
Media: Prevents clipping of text when scaling image edit screen.
Browse files Browse the repository at this point in the history
Props sabernhardt, audrasjb, afercia.
See #47115.


git-svn-id: https://develop.svn.wordpress.org/trunk@46354 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
antpb committed Sep 30, 2019
1 parent ba2d023 commit 32b7a5e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/js/_enqueues/lib/image-edit.js
Expand Up @@ -503,7 +503,7 @@


// If a response is returned, close the editor and show an error. // If a response is returned, close the editor and show an error.
if ( ret.error ) { if ( ret.error ) {
$('#imgedit-response-' + postid).html('<div class="error"><p>' + ret.error + '</p></div>'); $('#imgedit-response-' + postid).html('<div class="error" role="alert"><p>' + ret.error + '</p></div>');
imageEdit.close(postid); imageEdit.close(postid);
return; return;
} }
Expand All @@ -517,7 +517,7 @@
} }


if ( ret.msg ) { if ( ret.msg ) {
$('#imgedit-response-' + postid).html('<div class="updated"><p>' + ret.msg + '</p></div>'); $('#imgedit-response-' + postid).html('<div class="updated" role="alert"><p>' + ret.msg + '</p></div>');
} }


if ( self._view ) { if ( self._view ) {
Expand Down
5 changes: 4 additions & 1 deletion src/js/media/views/frame/select.js
Expand Up @@ -62,6 +62,8 @@ Select = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Select.prototype
* Create the default states on the frame. * Create the default states on the frame.
*/ */
createStates: function() { createStates: function() {
console.log("test");
this.on( 'content:render:edit-image', this.editState, this );
var options = this.options; var options = this.options;


if ( this.options.states ) { if ( this.options.states ) {
Expand All @@ -76,7 +78,8 @@ Select = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Select.prototype
multiple: options.multiple, multiple: options.multiple,
title: options.title, title: options.title,
priority: 20 priority: 20
}) }),
new wp.media.controller.EditImage( { model: this.options.editImage } ),
]); ]);
}, },


Expand Down
6 changes: 6 additions & 0 deletions src/wp-admin/css/edit.css
Expand Up @@ -655,6 +655,12 @@ form#tags-filter {
margin-bottom: 20px; margin-bottom: 20px;
} }


.wp_attachment_details .attachment-content-description {
margin-top: 0.5385em;
display: inline-block;
min-height: 1.6923em;
}

/* Suggested text for privacy policy */ /* Suggested text for privacy policy */
.wp-privacy-policy-guide { .wp-privacy-policy-guide {
max-width: 1000px; max-width: 1000px;
Expand Down
16 changes: 15 additions & 1 deletion src/wp-admin/css/media.css
Expand Up @@ -800,6 +800,11 @@ border color while dragging a file over the uploader drop area */
margin-bottom: 5px; margin-bottom: 5px;
} }


.attachment-details .setting + .description a:focus {
/* Only visible in Windows High Contrast mode */
outline: 1px solid transparent;
}

.wp_attachment_details .attachment-alt-text-description { .wp_attachment_details .attachment-alt-text-description {
margin-top: 5px; margin-top: 5px;
} }
Expand Down Expand Up @@ -1114,10 +1119,14 @@ span.imgedit-scale-warn {
padding: 10px; padding: 10px;
} }


.imgedit-settings .imgedit-original-dimensions {
display: inline-block;
}

.imgedit-settings .imgedit-scale input[type="text"], .imgedit-settings .imgedit-scale input[type="text"],
.imgedit-settings .imgedit-crop-ratio input[type="text"], .imgedit-settings .imgedit-crop-ratio input[type="text"],
.imgedit-settings .imgedit-crop-sel input[type="text"] { .imgedit-settings .imgedit-crop-sel input[type="text"] {
width: 50px; width: 80px;
font-size: 14px; font-size: 14px;
padding: 5px 8px; padding: 5px 8px;
} }
Expand All @@ -1130,6 +1139,11 @@ span.imgedit-scale-warn {
color: #444; color: #444;
} }


.imgedit-settings .imgedit-scale-button-wrapper {
margin-top: 0.3077em;
display: block;
}

.imgedit-settings .imgedit-scale .button { .imgedit-settings .imgedit-scale .button {
margin-bottom: 0; margin-bottom: 0;
} }
Expand Down
10 changes: 5 additions & 5 deletions src/wp-admin/includes/image-edit.php
Expand Up @@ -38,9 +38,9 @@ function wp_image_editor( $post_id, $msg = false ) {


if ( $msg ) { if ( $msg ) {
if ( isset( $msg->error ) ) { if ( isset( $msg->error ) ) {
$note = "<div class='error'><p>$msg->error</p></div>"; $note = "<div class='error' tabindex='-1' role='alert'><p>$msg->error</p></div>";
} elseif ( isset( $msg->msg ) ) { } elseif ( isset( $msg->msg ) ) {
$note = "<div class='updated'><p>$msg->msg</p></div>"; $note = "<div class='updated' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
} }
} }


Expand All @@ -62,7 +62,7 @@ function wp_image_editor( $post_id, $msg = false ) {
printf( printf(
/* translators: %s: Image width and height in pixels. */ /* translators: %s: Image width and height in pixels. */
__( 'Original dimensions %s' ), __( 'Original dimensions %s' ),
$meta['width'] . ' &times; ' . $meta['height'] '<span class="imgedit-original-dimensions">' . $meta['width'] . ' &times; ' . $meta['height'] . '</span>'
); );
?> ?>
</p> </p>
Expand All @@ -78,7 +78,7 @@ function wp_image_editor( $post_id, $msg = false ) {
<label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label> <label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label>
<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> <input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span> <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span>
<input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /> <div class="imgedit-scale-button-wrapper"><input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /></div>
</div> </div>
</fieldset> </fieldset>


Expand Down Expand Up @@ -235,7 +235,7 @@ function wp_image_editor( $post_id, $msg = false ) {
<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />


<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand( 1, 99999 ); ?>" alt="" /> <img id="image-preview-<?php echo $post_id; ?>" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&amp;_ajax_nonce=<?php echo $nonce; ?>&amp;postid=<?php echo $post_id; ?>&amp;rand=<?php echo rand( 1, 99999 ); ?>" alt="" />
</div> </div>


<div class="imgedit-submit"> <div class="imgedit-submit">
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/media.php
Expand Up @@ -3207,7 +3207,7 @@ function edit_form_image_editor( $post ) {


?> ?>


<label for="attachment_content"><strong><?php _e( 'Description' ); ?></strong> <label for="attachment_content" class="attachment-content-description"><strong><?php _e( 'Description' ); ?></strong>
<?php <?php


if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) { if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/css/editor.css
Expand Up @@ -1322,7 +1322,7 @@ i.mce-i-wp_code:before {
.wp-core-ui .quicktags-toolbar input.button.button-small { .wp-core-ui .quicktags-toolbar input.button.button-small {
/* .button-small is normally 11px, but a bit too small for these buttons. */ /* .button-small is normally 11px, but a bit too small for these buttons. */
font-size: 12px; font-size: 12px;
height: 26px; min-height: 26px;
line-height: 2; line-height: 2;
} }
} }
Expand Down

0 comments on commit 32b7a5e

Please sign in to comment.