26 $big = max( $meta['width'], $meta['height'] ); |
26 $big = max( $meta['width'], $meta['height'] ); |
27 } else { |
27 } else { |
28 die( __( 'Image data does not exist. Please re-upload the image.' ) ); |
28 die( __( 'Image data does not exist. Please re-upload the image.' ) ); |
29 } |
29 } |
30 |
30 |
31 $sizer = $big > 400 ? 400 / $big : 1; |
31 $sizer = $big > 600 ? 600 / $big : 1; |
32 |
32 |
33 $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
33 $backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true ); |
34 $can_restore = false; |
34 $can_restore = false; |
|
35 |
35 if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { |
36 if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { |
36 $can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file']; |
37 $can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file']; |
37 } |
38 } |
38 |
39 |
39 if ( $msg ) { |
40 if ( $msg ) { |
40 if ( isset( $msg->error ) ) { |
41 if ( isset( $msg->error ) ) { |
41 $note = "<div class='notice notice-error' tabindex='-1' role='alert'><p>$msg->error</p></div>"; |
42 $note = "<div class='notice notice-error' role='alert'><p>$msg->error</p></div>"; |
42 } elseif ( isset( $msg->msg ) ) { |
43 } elseif ( isset( $msg->msg ) ) { |
43 $note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>"; |
44 $note = "<div class='notice notice-success' role='alert'><p>$msg->msg</p></div>"; |
44 } |
45 } |
45 } |
46 } |
46 $edit_custom_sizes = false; |
47 |
47 /** |
48 /** |
48 * Filters whether custom sizes are available options for image editing. |
49 * Shows the settings in the Image Editor that allow selecting to edit only the thumbnail of an image. |
49 * |
50 * |
50 * @since 6.0.0 |
51 * @since 6.3.0 |
51 * |
52 * |
52 * @param bool|string[] $edit_custom_sizes True if custom sizes can be edited or array of custom size names. |
53 * @param bool $show Whether to show the settings in the Image Editor. Default false. |
53 */ |
54 */ |
54 $edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes ); |
55 $edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false ); |
|
56 |
55 ?> |
57 ?> |
56 <div class="imgedit-wrap wp-clearfix"> |
58 <div class="imgedit-wrap wp-clearfix"> |
57 <div id="imgedit-panel-<?php echo $post_id; ?>"> |
59 <div id="imgedit-panel-<?php echo $post_id; ?>"> |
58 |
60 <?php echo $note; ?> |
59 <div class="imgedit-panel-content wp-clearfix"> |
61 <div class="imgedit-panel-content imgedit-panel-tools wp-clearfix"> |
60 <?php echo $note; ?> |
|
61 <div class="imgedit-menu wp-clearfix"> |
62 <div class="imgedit-menu wp-clearfix"> |
62 <button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button> |
63 <button type="button" onclick="imageEdit.toggleCropTool( <?php echo "$post_id, '$nonce'"; ?>, this );" aria-expanded="false" aria-controls="imgedit-crop" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button> |
|
64 <button type="button" class="imgedit-scale button" onclick="imageEdit.toggleControls(this);" aria-expanded="false" aria-controls="imgedit-scale"><?php esc_html_e( 'Scale' ); ?></button> |
|
65 <div class="imgedit-rotate-menu-container"> |
|
66 <button type="button" aria-controls="imgedit-rotate-menu" class="imgedit-rotate button" aria-expanded="false" onclick="imageEdit.togglePopup(this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Image Rotation' ); ?></button> |
|
67 <div id="imgedit-rotate-menu" class="imgedit-popup-menu"> |
63 <?php |
68 <?php |
64 |
|
65 // On some setups GD library does not provide imagerotate() - Ticket #11536. |
69 // On some setups GD library does not provide imagerotate() - Ticket #11536. |
66 if ( wp_image_editor_supports( |
70 if ( wp_image_editor_supports( |
67 array( |
71 array( |
68 'mime_type' => get_post_mime_type( $post_id ), |
72 'mime_type' => get_post_mime_type( $post_id ), |
69 'methods' => array( 'rotate' ), |
73 'methods' => array( 'rotate' ), |
70 ) |
74 ) |
71 ) ) { |
75 ) ) { |
72 $note_no_rotate = ''; |
76 $note_no_rotate = ''; |
73 ?> |
77 ?> |
74 <button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate left' ); ?></button> |
78 <button type="button" class="imgedit-rleft button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90° left' ); ?></button> |
75 <button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate right' ); ?></button> |
79 <button type="button" class="imgedit-rright button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90° right' ); ?></button> |
|
80 <button type="button" class="imgedit-rfull button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(180, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 180°' ); ?></button> |
76 <?php |
81 <?php |
77 } else { |
82 } else { |
78 $note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>'; |
83 $note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>'; |
79 ?> |
84 ?> |
80 <button type="button" class="imgedit-rleft button disabled" disabled></button> |
85 <button type="button" class="imgedit-rleft button disabled" disabled></button> |
81 <button type="button" class="imgedit-rright button disabled" disabled></button> |
86 <button type="button" class="imgedit-rright button disabled" disabled></button> |
82 <?php } ?> |
87 <?php |
83 |
88 } |
84 <button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button> |
89 ?> |
85 <button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button> |
90 <hr /> |
86 |
91 <button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button> |
87 <br class="imgedit-undo-redo-separator" /> |
92 <button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button> |
|
93 <?php echo $note_no_rotate; ?> |
|
94 </div> |
|
95 </div> |
|
96 </div> |
|
97 <div class="imgedit-submit imgedit-menu"> |
88 <button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><?php esc_html_e( 'Undo' ); ?></button> |
98 <button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><?php esc_html_e( 'Undo' ); ?></button> |
89 <button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><?php esc_html_e( 'Redo' ); ?></button> |
99 <button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><?php esc_html_e( 'Redo' ); ?></button> |
90 <?php echo $note_no_rotate; ?> |
100 <button type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn"><?php esc_html_e( 'Cancel Editing' ); ?></button> |
91 </div> |
101 <button type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn"><?php esc_html_e( 'Save Edits' ); ?></button> |
92 |
|
93 <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" /> |
|
94 <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> |
|
95 <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" /> |
|
96 <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" /> |
|
97 <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
|
98 <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> |
|
99 |
|
100 <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> |
|
101 <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" |
|
102 src="<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=imgedit-preview&_ajax_nonce=' . $nonce . '&postid=' . $post_id . '&rand=' . rand( 1, 99999 ); ?>" alt="" /> |
|
103 </div> |
|
104 |
|
105 <div class="imgedit-submit"> |
|
106 <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" /> |
|
107 <input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" /> |
|
108 </div> |
102 </div> |
109 </div> |
103 </div> |
110 |
104 |
111 <div class="imgedit-settings"> |
105 <div class="imgedit-panel-content wp-clearfix"> |
112 <div class="imgedit-group"> |
106 <div class="imgedit-tools"> |
113 <div class="imgedit-group-top"> |
107 <input type="hidden" id="imgedit-nonce-<?php echo $post_id; ?>" value="<?php echo $nonce; ?>" /> |
114 <h2><?php _e( 'Scale Image' ); ?></h2> |
108 <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" /> |
115 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Scale Image Help' ); ?></span></button> |
109 <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> |
116 <div class="imgedit-help"> |
110 <input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" /> |
117 <p><?php _e( 'You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.' ); ?></p> |
111 <input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" /> |
|
112 <input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
|
113 <input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" /> |
|
114 |
|
115 <div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap"> |
|
116 <div class="imgedit-crop-grid"></div> |
|
117 <img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" |
|
118 src="<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=imgedit-preview&_ajax_nonce=' . $nonce . '&postid=' . $post_id . '&rand=' . rand( 1, 99999 ); ?>" alt="" /> |
|
119 </div> |
118 </div> |
120 </div> |
119 <?php if ( isset( $meta['width'], $meta['height'] ) ) : ?> |
121 <div class="imgedit-settings"> |
120 <p> |
122 <div class="imgedit-tool-active"> |
121 <?php |
123 <div class="imgedit-group"> |
122 printf( |
124 <div id="imgedit-scale" tabindex="-1" class="imgedit-group-controls"> |
123 /* translators: %s: Image width and height in pixels. */ |
125 <div class="imgedit-group-top"> |
124 __( 'Original dimensions %s' ), |
126 <h2><?php _e( 'Scale Image' ); ?></h2> |
125 '<span class="imgedit-original-dimensions">' . $meta['width'] . ' × ' . $meta['height'] . '</span>' |
127 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"> |
126 ); |
128 <?php |
127 ?> |
129 /* translators: Hidden accessibility text. */ |
128 </p> |
130 esc_html_e( 'Scale Image Help' ); |
129 <?php endif; ?> |
131 ?> |
130 <div class="imgedit-submit"> |
132 </span></button> |
131 |
133 <div class="imgedit-help"> |
132 <fieldset class="imgedit-scale"> |
134 <p><?php _e( 'You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.' ); ?></p> |
133 <legend><?php _e( 'New dimensions:' ); ?></legend> |
135 </div> |
134 <div class="nowrap"> |
136 <?php if ( isset( $meta['width'], $meta['height'] ) ) : ?> |
135 <label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale width' ); ?></label> |
137 <p> |
136 <input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
138 <?php |
137 <span class="imgedit-separator" aria-hidden="true">×</span> |
139 printf( |
138 <label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label> |
140 /* translators: %s: Image width and height in pixels. */ |
139 <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; ?>" /> |
141 __( 'Original dimensions %s' ), |
140 <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span> |
142 '<span class="imgedit-original-dimensions">' . $meta['width'] . ' × ' . $meta['height'] . '</span>' |
141 <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> |
143 ); |
142 </div> |
144 ?> |
143 </fieldset> |
145 </p> |
144 |
146 <?php endif; ?> |
|
147 <div class="imgedit-submit"> |
|
148 <fieldset class="imgedit-scale-controls"> |
|
149 <legend><?php _e( 'New dimensions:' ); ?></legend> |
|
150 <div class="nowrap"> |
|
151 <label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
152 <?php |
|
153 /* translators: Hidden accessibility text. */ |
|
154 _e( 'scale height' ); |
|
155 ?> |
|
156 </label> |
|
157 <input type="number" step="1" min="0" max="<?php echo isset( $meta['width'] ) ? $meta['width'] : ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" /> |
|
158 <span class="imgedit-separator" aria-hidden="true">×</span> |
|
159 <label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label> |
|
160 <input type="number" step="1" min="0" max="<?php echo isset( $meta['height'] ) ? $meta['height'] : ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>" 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; ?>" /> |
|
161 <button id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary"><?php esc_html_e( 'Scale' ); ?></button> |
|
162 </div> |
|
163 <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>"><span class="dashicons dashicons-warning" aria-hidden="true"></span><?php esc_html_e( 'Images cannot be scaled to a size larger than the original.' ); ?></span> |
|
164 </fieldset> |
|
165 </div> |
|
166 </div> |
|
167 </div> |
|
168 </div> |
|
169 |
|
170 <?php if ( $can_restore ) { ?> |
|
171 <div class="imgedit-group"> |
|
172 <div class="imgedit-group-top"> |
|
173 <h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link" aria-expanded="false"><?php _e( 'Restore original image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2> |
|
174 <div class="imgedit-help imgedit-restore"> |
|
175 <p> |
|
176 <?php |
|
177 _e( 'Discard any changes and restore the original image.' ); |
|
178 if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) { |
|
179 echo ' ' . __( 'Previously edited copies of the image will not be deleted.' ); |
|
180 } |
|
181 ?> |
|
182 </p> |
|
183 <div class="imgedit-submit"> |
|
184 <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> /> |
|
185 </div> |
|
186 </div> |
|
187 </div> |
|
188 </div> |
|
189 <?php } ?> |
|
190 <div class="imgedit-group"> |
|
191 <div id="imgedit-crop" tabindex="-1" class="imgedit-group-controls"> |
|
192 <div class="imgedit-group-top"> |
|
193 <h2><?php _e( 'Crop Image' ); ?></h2> |
|
194 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"> |
|
195 <?php |
|
196 /* translators: Hidden accessibility text. */ |
|
197 _e( 'Image Crop Help' ); |
|
198 ?> |
|
199 </span></button> |
|
200 <div class="imgedit-help"> |
|
201 <p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p> |
|
202 <p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br /> |
|
203 <?php _e( 'The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.' ); ?></p> |
|
204 |
|
205 <p><strong><?php _e( 'Crop Selection' ); ?></strong><br /> |
|
206 <?php _e( 'Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.' ); ?></p> |
|
207 </div> |
|
208 </div> |
|
209 <fieldset class="imgedit-crop-ratio"> |
|
210 <legend><?php _e( 'Aspect ratio:' ); ?></legend> |
|
211 <div class="nowrap"> |
|
212 <label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
213 <?php |
|
214 /* translators: Hidden accessibility text. */ |
|
215 _e( 'crop ratio width' ); |
|
216 ?> |
|
217 </label> |
|
218 <input type="number" step="1" min="1" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" /> |
|
219 <span class="imgedit-separator" aria-hidden="true">:</span> |
|
220 <label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
221 <?php |
|
222 /* translators: Hidden accessibility text. */ |
|
223 _e( 'crop ratio height' ); |
|
224 ?> |
|
225 </label> |
|
226 <input type="number" step="1" min="0" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" /> |
|
227 </div> |
|
228 </fieldset> |
|
229 <fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel"> |
|
230 <legend><?php _e( 'Selection:' ); ?></legend> |
|
231 <div class="nowrap"> |
|
232 <label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
233 <?php |
|
234 /* translators: Hidden accessibility text. */ |
|
235 _e( 'selection width' ); |
|
236 ?> |
|
237 </label> |
|
238 <input type="number" step="1" min="0" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> |
|
239 <span class="imgedit-separator" aria-hidden="true">×</span> |
|
240 <label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
241 <?php |
|
242 /* translators: Hidden accessibility text. */ |
|
243 _e( 'selection height' ); |
|
244 ?> |
|
245 </label> |
|
246 <input type="number" step="1" min="0" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> |
|
247 </div> |
|
248 </fieldset> |
|
249 <fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel"> |
|
250 <legend><?php _e( 'Starting Coordinates:' ); ?></legend> |
|
251 <div class="nowrap"> |
|
252 <label for="imgedit-start-x-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
253 <?php |
|
254 /* translators: Hidden accessibility text. */ |
|
255 _e( 'horizontal start position' ); |
|
256 ?> |
|
257 </label> |
|
258 <input type="number" step="1" min="0" id="imgedit-start-x-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" value="0" /> |
|
259 <span class="imgedit-separator" aria-hidden="true">×</span> |
|
260 <label for="imgedit-start-y-<?php echo $post_id; ?>" class="screen-reader-text"> |
|
261 <?php |
|
262 /* translators: Hidden accessibility text. */ |
|
263 _e( 'vertical start position' ); |
|
264 ?> |
|
265 </label> |
|
266 <input type="number" step="1" min="0" id="imgedit-start-y-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" value="0" /> |
|
267 </div> |
|
268 </fieldset> |
|
269 <div class="imgedit-crop-apply imgedit-menu container"> |
|
270 <button class="button-primary" type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this );" class="imgedit-crop-apply button"><?php esc_html_e( 'Apply Crop' ); ?></button> <button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this );" class="imgedit-crop-clear button" disabled="disabled"><?php esc_html_e( 'Clear Crop' ); ?></button> |
|
271 </div> |
|
272 </div> |
145 </div> |
273 </div> |
146 </div> |
274 </div> |
147 </div> |
275 |
148 |
276 <?php |
149 <?php if ( $can_restore ) { ?> |
277 if ( $edit_thumbnails_separately && $thumb && $sub_sizes ) { |
150 |
278 $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); |
151 <div class="imgedit-group"> |
279 ?> |
152 <div class="imgedit-group-top"> |
280 |
153 <h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link" aria-expanded="false"><?php _e( 'Restore original image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2> |
281 <div class="imgedit-group imgedit-applyto"> |
154 <div class="imgedit-help imgedit-restore"> |
282 <div class="imgedit-group-top"> |
155 <p> |
283 <h2><?php _e( 'Thumbnail Settings' ); ?></h2> |
|
284 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"> |
156 <?php |
285 <?php |
157 _e( 'Discard any changes and restore the original image.' ); |
286 /* translators: Hidden accessibility text. */ |
158 |
287 esc_html_e( 'Thumbnail Settings Help' ); |
159 if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) { |
|
160 echo ' ' . __( 'Previously edited copies of the image will not be deleted.' ); |
|
161 } |
|
162 ?> |
288 ?> |
163 </p> |
289 </span></button> |
164 <div class="imgedit-submit"> |
290 <div class="imgedit-help"> |
165 <input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> /> |
291 <p><?php _e( 'You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.' ); ?></p> |
|
292 </div> |
166 </div> |
293 </div> |
|
294 <div class="imgedit-thumbnail-preview-group"> |
|
295 <figure class="imgedit-thumbnail-preview"> |
|
296 <img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" /> |
|
297 <figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption> |
|
298 </figure> |
|
299 <div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target"> |
|
300 <fieldset> |
|
301 <legend><?php _e( 'Apply changes to:' ); ?></legend> |
|
302 |
|
303 <span class="imgedit-label"> |
|
304 <input type="radio" id="imgedit-target-all" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" /> |
|
305 <label for="imgedit-target-all"><?php _e( 'All image sizes' ); ?></label> |
|
306 </span> |
|
307 |
|
308 <span class="imgedit-label"> |
|
309 <input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" /> |
|
310 <label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label> |
|
311 </span> |
|
312 |
|
313 <span class="imgedit-label"> |
|
314 <input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" /> |
|
315 <label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label> |
|
316 </span> |
|
317 |
|
318 </fieldset> |
|
319 </div> |
167 </div> |
320 </div> |
168 </div> |
321 </div> |
169 </div> |
|
170 |
|
171 <?php } ?> |
322 <?php } ?> |
172 |
|
173 <div class="imgedit-group"> |
|
174 <div class="imgedit-group-top"> |
|
175 <h2><?php _e( 'Image Crop' ); ?></h2> |
|
176 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Image Crop Help' ); ?></span></button> |
|
177 |
|
178 <div class="imgedit-help"> |
|
179 <p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p> |
|
180 |
|
181 <p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br /> |
|
182 <?php _e( 'The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.' ); ?></p> |
|
183 |
|
184 <p><strong><?php _e( 'Crop Selection' ); ?></strong><br /> |
|
185 <?php _e( 'Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.' ); ?></p> |
|
186 </div> |
323 </div> |
187 </div> |
324 </div> |
188 |
325 |
189 <fieldset class="imgedit-crop-ratio"> |
|
190 <legend><?php _e( 'Aspect ratio:' ); ?></legend> |
|
191 <div class="nowrap"> |
|
192 <label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></label> |
|
193 <input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" /> |
|
194 <span class="imgedit-separator" aria-hidden="true">:</span> |
|
195 <label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></label> |
|
196 <input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" /> |
|
197 </div> |
|
198 </fieldset> |
|
199 |
|
200 <fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel"> |
|
201 <legend><?php _e( 'Selection:' ); ?></legend> |
|
202 <div class="nowrap"> |
|
203 <label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'selection width' ); ?></label> |
|
204 <input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> |
|
205 <span class="imgedit-separator" aria-hidden="true">×</span> |
|
206 <label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'selection height' ); ?></label> |
|
207 <input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" /> |
|
208 </div> |
|
209 </fieldset> |
|
210 |
|
211 </div> |
326 </div> |
212 |
327 |
213 <?php |
|
214 if ( $thumb && $sub_sizes ) { |
|
215 $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); |
|
216 ?> |
|
217 |
|
218 <div class="imgedit-group imgedit-applyto"> |
|
219 <div class="imgedit-group-top"> |
|
220 <h2><?php _e( 'Thumbnail Settings' ); ?></h2> |
|
221 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail Settings Help' ); ?></span></button> |
|
222 <div class="imgedit-help"> |
|
223 <p><?php _e( 'You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.' ); ?></p> |
|
224 </div> |
|
225 </div> |
|
226 |
|
227 <figure class="imgedit-thumbnail-preview"> |
|
228 <img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" /> |
|
229 <figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption> |
|
230 </figure> |
|
231 |
|
232 <div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target"> |
|
233 <fieldset> |
|
234 <legend><?php _e( 'Apply changes to:' ); ?></legend> |
|
235 |
|
236 <span class="imgedit-label"> |
|
237 <input type="radio" id="imgedit-target-all" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" /> |
|
238 <label for="imgedit-target-all"><?php _e( 'All image sizes' ); ?></label> |
|
239 </span> |
|
240 |
|
241 <span class="imgedit-label"> |
|
242 <input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" /> |
|
243 <label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label> |
|
244 </span> |
|
245 |
|
246 <span class="imgedit-label"> |
|
247 <input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" /> |
|
248 <label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label> |
|
249 </span> |
|
250 <?php |
|
251 if ( $edit_custom_sizes ) { |
|
252 if ( ! is_array( $edit_custom_sizes ) ) { |
|
253 $edit_custom_sizes = get_intermediate_image_sizes(); |
|
254 } |
|
255 foreach ( array_unique( $edit_custom_sizes ) as $key => $size ) { |
|
256 if ( array_key_exists( $size, $meta['sizes'] ) ) { |
|
257 if ( 'thumbnail' === $size ) { |
|
258 continue; |
|
259 } |
|
260 ?> |
|
261 <span class="imgedit-label"> |
|
262 <input type="radio" id="imgedit-target-custom<?php echo esc_attr( $key ); ?>" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr( $size ); ?>" /> |
|
263 <label for="imgedit-target-custom<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $size ); ?></label> |
|
264 </span> |
|
265 <?php |
|
266 } |
|
267 } |
|
268 } |
|
269 ?> |
|
270 </fieldset> |
|
271 </div> |
|
272 </div> |
|
273 |
|
274 <?php } ?> |
|
275 |
|
276 </div> |
|
277 |
|
278 </div> |
|
279 <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div> |
328 <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div> |
280 <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> |
329 <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> |
281 </div> |
330 </div> |
282 <?php |
331 <?php |
283 } |
332 } |