31 $sizer = $big > 400 ? 400 / $big : 1; |
31 $sizer = $big > 400 ? 400 / $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 if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { |
35 if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) { |
36 $can_restore = $backup_sizes['full-orig']['file'] != wp_basename( $meta['file'] ); |
36 $can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file']; |
37 } |
37 } |
38 |
38 |
39 if ( $msg ) { |
39 if ( $msg ) { |
40 if ( isset( $msg->error ) ) { |
40 if ( isset( $msg->error ) ) { |
41 $note = "<div class='error'><p>$msg->error</p></div>"; |
41 $note = "<div class='notice notice-error' tabindex='-1' role='alert'><p>$msg->error</p></div>"; |
42 } elseif ( isset( $msg->msg ) ) { |
42 } elseif ( isset( $msg->msg ) ) { |
43 $note = "<div class='updated'><p>$msg->msg</p></div>"; |
43 $note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>"; |
44 } |
44 } |
45 } |
45 } |
46 |
46 |
47 ?> |
47 ?> |
48 <div class="imgedit-wrap wp-clearfix"> |
48 <div class="imgedit-wrap wp-clearfix"> |
49 <div id="imgedit-panel-<?php echo $post_id; ?>"> |
49 <div id="imgedit-panel-<?php echo $post_id; ?>"> |
50 |
50 |
51 <div class="imgedit-settings"> |
|
52 <div class="imgedit-group"> |
|
53 <div class="imgedit-group-top"> |
|
54 <h2><?php _e( 'Scale Image' ); ?></h2> |
|
55 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Scale Image Help' ); ?></span></button> |
|
56 <div class="imgedit-help"> |
|
57 <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> |
|
58 </div> |
|
59 <?php if ( isset( $meta['width'], $meta['height'] ) ) : ?> |
|
60 <p><?php printf( __( 'Original dimensions %s' ), $meta['width'] . ' × ' . $meta['height'] ); ?></p> |
|
61 <?php endif ?> |
|
62 <div class="imgedit-submit"> |
|
63 |
|
64 <fieldset class="imgedit-scale"> |
|
65 <legend><?php _e( 'New dimensions:' ); ?></legend> |
|
66 <div class="nowrap"> |
|
67 <label><span class="screen-reader-text"><?php _e( 'scale width' ); ?></span> |
|
68 <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; ?>" /> |
|
69 </label> |
|
70 <span class="imgedit-separator">×</span> |
|
71 <label><span class="screen-reader-text"><?php _e( 'scale height' ); ?></span> |
|
72 <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; ?>" /> |
|
73 </label> |
|
74 <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span> |
|
75 <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' ); ?>" /> |
|
76 </div> |
|
77 </fieldset> |
|
78 |
|
79 </div> |
|
80 </div> |
|
81 </div> |
|
82 |
|
83 <?php if ( $can_restore ) { ?> |
|
84 |
|
85 <div class="imgedit-group"> |
|
86 <div class="imgedit-group-top"> |
|
87 <h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link"><?php _e( 'Restore Original Image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2> |
|
88 <div class="imgedit-help"> |
|
89 <p> |
|
90 <?php |
|
91 _e( 'Discard any changes and restore the original image.' ); |
|
92 |
|
93 if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) { |
|
94 echo ' ' . __( 'Previously edited copies of the image will not be deleted.' ); |
|
95 } |
|
96 |
|
97 ?> |
|
98 </p> |
|
99 <div class="imgedit-submit"> |
|
100 <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; ?> /> |
|
101 </div> |
|
102 </div> |
|
103 </div> |
|
104 </div> |
|
105 |
|
106 <?php } ?> |
|
107 |
|
108 <div class="imgedit-group"> |
|
109 <div class="imgedit-group-top"> |
|
110 <h2><?php _e( 'Image Crop' ); ?></h2> |
|
111 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Image Crop Help' ); ?></span></button> |
|
112 |
|
113 <div class="imgedit-help"> |
|
114 <p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p> |
|
115 |
|
116 <p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br /> |
|
117 <?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> |
|
118 |
|
119 <p><strong><?php _e( 'Crop Selection' ); ?></strong><br /> |
|
120 <?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> |
|
121 </div> |
|
122 </div> |
|
123 |
|
124 <fieldset class="imgedit-crop-ratio"> |
|
125 <legend><?php _e( 'Aspect ratio:' ); ?></legend> |
|
126 <div class="nowrap"> |
|
127 <label><span class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></span> |
|
128 <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)" /> |
|
129 </label> |
|
130 <span class="imgedit-separator">:</span> |
|
131 <label><span class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></span> |
|
132 <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)" /> |
|
133 </label> |
|
134 </div> |
|
135 </fieldset> |
|
136 |
|
137 <fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel"> |
|
138 <legend><?php _e( 'Selection:' ); ?></legend> |
|
139 <div class="nowrap"> |
|
140 <label><span class="screen-reader-text"><?php _e( 'selection width' ); ?></span> |
|
141 <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)" /> |
|
142 </label> |
|
143 <span class="imgedit-separator">×</span> |
|
144 <label><span class="screen-reader-text"><?php _e( 'selection height' ); ?></span> |
|
145 <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)" /> |
|
146 </label> |
|
147 </div> |
|
148 </fieldset> |
|
149 |
|
150 </div> |
|
151 |
|
152 <?php |
|
153 if ( $thumb && $sub_sizes ) { |
|
154 $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); |
|
155 ?> |
|
156 |
|
157 <div class="imgedit-group imgedit-applyto"> |
|
158 <div class="imgedit-group-top"> |
|
159 <h2><?php _e( 'Thumbnail Settings' ); ?></h2> |
|
160 <button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail Settings Help' ); ?></span></button> |
|
161 <p class="imgedit-help"><?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> |
|
162 </div> |
|
163 |
|
164 <figure class="imgedit-thumbnail-preview"> |
|
165 <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" /> |
|
166 <figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption> |
|
167 </figure> |
|
168 |
|
169 <div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target"> |
|
170 <fieldset> |
|
171 <legend><strong><?php _e( 'Apply changes to:' ); ?></strong></legend> |
|
172 |
|
173 <label class="imgedit-label"> |
|
174 <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" /> |
|
175 <?php _e( 'All image sizes' ); ?></label> |
|
176 |
|
177 <label class="imgedit-label"> |
|
178 <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" /> |
|
179 <?php _e( 'Thumbnail' ); ?></label> |
|
180 |
|
181 <label class="imgedit-label"> |
|
182 <input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" /> |
|
183 <?php _e( 'All sizes except thumbnail' ); ?></label> |
|
184 </fieldset> |
|
185 </div> |
|
186 </div> |
|
187 |
|
188 <?php } ?> |
|
189 |
|
190 </div> |
|
191 |
|
192 <div class="imgedit-panel-content wp-clearfix"> |
51 <div class="imgedit-panel-content wp-clearfix"> |
193 <?php echo $note; ?> |
52 <?php echo $note; ?> |
194 <div class="imgedit-menu wp-clearfix"> |
53 <div class="imgedit-menu wp-clearfix"> |
195 <button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button> |
54 <button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button> |
196 <?php |
55 <?php |
197 |
56 |
198 // On some setups GD library does not provide imagerotate() - Ticket #11536 |
57 // On some setups GD library does not provide imagerotate() - Ticket #11536. |
199 if ( wp_image_editor_supports( |
58 if ( wp_image_editor_supports( |
200 array( |
59 array( |
201 'mime_type' => get_post_mime_type( $post_id ), |
60 'mime_type' => get_post_mime_type( $post_id ), |
202 'methods' => array( 'rotate' ), |
61 'methods' => array( 'rotate' ), |
203 ) |
62 ) |
204 ) ) { |
63 ) ) { |
205 $note_no_rotate = ''; |
64 $note_no_rotate = ''; |
206 ?> |
65 ?> |
207 <button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate counter-clockwise' ); ?></span></button> |
66 <button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate left' ); ?></button> |
208 <button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate clockwise' ); ?></span></button> |
67 <button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate right' ); ?></button> |
209 <?php |
68 <?php |
210 } else { |
69 } else { |
211 $note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>'; |
70 $note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>'; |
212 ?> |
71 ?> |
213 <button type="button" class="imgedit-rleft button disabled" disabled></button> |
72 <button type="button" class="imgedit-rleft button disabled" disabled></button> |
214 <button type="button" class="imgedit-rright button disabled" disabled></button> |
73 <button type="button" class="imgedit-rright button disabled" disabled></button> |
215 <?php } ?> |
74 <?php } ?> |
216 |
75 |
217 <button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><span class="screen-reader-text"><?php esc_html_e( 'Flip vertically' ); ?></span></button> |
76 <button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button> |
218 <button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><span class="screen-reader-text"><?php esc_html_e( 'Flip horizontally' ); ?></span></button> |
77 <button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button> |
219 |
78 |
220 <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><span class="screen-reader-text"><?php esc_html_e( 'Undo' ); ?></span></button> |
79 <br class="imgedit-undo-redo-separator" /> |
221 <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><span class="screen-reader-text"><?php esc_html_e( 'Redo' ); ?></span></button> |
80 <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> |
|
81 <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> |
222 <?php echo $note_no_rotate; ?> |
82 <?php echo $note_no_rotate; ?> |
223 </div> |
83 </div> |
224 |
84 |
225 <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" /> |
85 <input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" /> |
226 <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> |
86 <input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" /> |
237 <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" /> |
97 <input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" /> |
238 <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' ); ?>" /> |
98 <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' ); ?>" /> |
239 </div> |
99 </div> |
240 </div> |
100 </div> |
241 |
101 |
|
102 <div class="imgedit-settings"> |
|
103 <div class="imgedit-group"> |
|
104 <div class="imgedit-group-top"> |
|
105 <h2><?php _e( 'Scale Image' ); ?></h2> |
|
106 <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> |
|
107 <div class="imgedit-help"> |
|
108 <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> |
|
109 </div> |
|
110 <?php if ( isset( $meta['width'], $meta['height'] ) ) : ?> |
|
111 <p> |
|
112 <?php |
|
113 printf( |
|
114 /* translators: %s: Image width and height in pixels. */ |
|
115 __( 'Original dimensions %s' ), |
|
116 '<span class="imgedit-original-dimensions">' . $meta['width'] . ' × ' . $meta['height'] . '</span>' |
|
117 ); |
|
118 ?> |
|
119 </p> |
|
120 <?php endif ?> |
|
121 <div class="imgedit-submit"> |
|
122 |
|
123 <fieldset class="imgedit-scale"> |
|
124 <legend><?php _e( 'New dimensions:' ); ?></legend> |
|
125 <div class="nowrap"> |
|
126 <label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale width' ); ?></label> |
|
127 <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; ?>" /> |
|
128 <span class="imgedit-separator" aria-hidden="true">×</span> |
|
129 <label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label> |
|
130 <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; ?>" /> |
|
131 <span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span> |
|
132 <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> |
|
133 </div> |
|
134 </fieldset> |
|
135 |
|
136 </div> |
|
137 </div> |
|
138 </div> |
|
139 |
|
140 <?php if ( $can_restore ) { ?> |
|
141 |
|
142 <div class="imgedit-group"> |
|
143 <div class="imgedit-group-top"> |
|
144 <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> |
|
145 <div class="imgedit-help imgedit-restore"> |
|
146 <p> |
|
147 <?php |
|
148 _e( 'Discard any changes and restore the original image.' ); |
|
149 |
|
150 if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) { |
|
151 echo ' ' . __( 'Previously edited copies of the image will not be deleted.' ); |
|
152 } |
|
153 ?> |
|
154 </p> |
|
155 <div class="imgedit-submit"> |
|
156 <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; ?> /> |
|
157 </div> |
|
158 </div> |
|
159 </div> |
|
160 </div> |
|
161 |
|
162 <?php } ?> |
|
163 |
|
164 <div class="imgedit-group"> |
|
165 <div class="imgedit-group-top"> |
|
166 <h2><?php _e( 'Image Crop' ); ?></h2> |
|
167 <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> |
|
168 |
|
169 <div class="imgedit-help"> |
|
170 <p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p> |
|
171 |
|
172 <p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br /> |
|
173 <?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> |
|
174 |
|
175 <p><strong><?php _e( 'Crop Selection' ); ?></strong><br /> |
|
176 <?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> |
|
177 </div> |
|
178 </div> |
|
179 |
|
180 <fieldset class="imgedit-crop-ratio"> |
|
181 <legend><?php _e( 'Aspect ratio:' ); ?></legend> |
|
182 <div class="nowrap"> |
|
183 <label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'crop ratio width' ); ?></label> |
|
184 <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)" /> |
|
185 <span class="imgedit-separator" aria-hidden="true">:</span> |
|
186 <label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'crop ratio height' ); ?></label> |
|
187 <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)" /> |
|
188 </div> |
|
189 </fieldset> |
|
190 |
|
191 <fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel"> |
|
192 <legend><?php _e( 'Selection:' ); ?></legend> |
|
193 <div class="nowrap"> |
|
194 <label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'selection width' ); ?></label> |
|
195 <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)" /> |
|
196 <span class="imgedit-separator" aria-hidden="true">×</span> |
|
197 <label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'selection height' ); ?></label> |
|
198 <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)" /> |
|
199 </div> |
|
200 </fieldset> |
|
201 |
|
202 </div> |
|
203 |
|
204 <?php |
|
205 if ( $thumb && $sub_sizes ) { |
|
206 $thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 ); |
|
207 ?> |
|
208 |
|
209 <div class="imgedit-group imgedit-applyto"> |
|
210 <div class="imgedit-group-top"> |
|
211 <h2><?php _e( 'Thumbnail Settings' ); ?></h2> |
|
212 <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> |
|
213 <div class="imgedit-help"> |
|
214 <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> |
|
215 </div> |
|
216 </div> |
|
217 |
|
218 <figure class="imgedit-thumbnail-preview"> |
|
219 <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" /> |
|
220 <figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption> |
|
221 </figure> |
|
222 |
|
223 <div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target"> |
|
224 <fieldset> |
|
225 <legend><?php _e( 'Apply changes to:' ); ?></legend> |
|
226 |
|
227 <span class="imgedit-label"> |
|
228 <input type="radio" id="imgedit-target-all" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" /> |
|
229 <label for="imgedit-target-all"><?php _e( 'All image sizes' ); ?></label> |
|
230 </span> |
|
231 |
|
232 <span class="imgedit-label"> |
|
233 <input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" /> |
|
234 <label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label> |
|
235 </span> |
|
236 |
|
237 <span class="imgedit-label"> |
|
238 <input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" /> |
|
239 <label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label> |
|
240 </span> |
|
241 </fieldset> |
|
242 </div> |
|
243 </div> |
|
244 |
|
245 <?php } ?> |
|
246 |
|
247 </div> |
|
248 |
242 </div> |
249 </div> |
243 <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div> |
250 <div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div> |
244 <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> |
251 <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> |
245 </div> |
252 </div> |
246 <?php |
253 <?php |
327 * Returning a non-null value will short-circuit the save method, |
335 * Returning a non-null value will short-circuit the save method, |
328 * returning that value instead. |
336 * returning that value instead. |
329 * |
337 * |
330 * @since 3.5.0 |
338 * @since 3.5.0 |
331 * |
339 * |
|
340 * @param bool|null $override Value to return instead of saving. Default null. |
|
341 * @param string $filename Name of the file to be saved. |
|
342 * @param WP_Image_Editor $image The image editor instance. |
|
343 * @param string $mime_type The mime type of the image. |
|
344 * @param int $post_id Attachment post ID. |
|
345 */ |
|
346 $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); |
|
347 |
|
348 if ( null !== $saved ) { |
|
349 return $saved; |
|
350 } |
|
351 |
|
352 return $image->save( $filename, $mime_type ); |
|
353 } else { |
|
354 /* translators: 1: $image, 2: WP_Image_Editor */ |
|
355 _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) ); |
|
356 |
|
357 /** This filter is documented in wp-admin/includes/image-edit.php */ |
|
358 $image = apply_filters_deprecated( 'image_save_pre', array( $image, $post_id ), '3.5.0', 'image_editor_save_pre' ); |
|
359 |
|
360 /** |
|
361 * Filters whether to skip saving the image file. |
|
362 * |
|
363 * Returning a non-null value will short-circuit the save method, |
|
364 * returning that value instead. |
|
365 * |
|
366 * @since 2.9.0 |
|
367 * @deprecated 3.5.0 Use {@see 'wp_save_image_editor_file'} instead. |
|
368 * |
332 * @param mixed $override Value to return instead of saving. Default null. |
369 * @param mixed $override Value to return instead of saving. Default null. |
333 * @param string $filename Name of the file to be saved. |
370 * @param string $filename Name of the file to be saved. |
334 * @param WP_Image_Editor $image WP_Image_Editor instance. |
371 * @param WP_Image_Editor $image The image editor instance. |
335 * @param string $mime_type Image mime type. |
372 * @param string $mime_type The mime type of the image. |
336 * @param int $post_id Post ID. |
373 * @param int $post_id Attachment post ID. |
337 */ |
374 */ |
338 $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); |
375 $saved = apply_filters_deprecated( |
339 |
376 'wp_save_image_file', |
340 if ( null !== $saved ) { |
377 array( null, $filename, $image, $mime_type, $post_id ), |
341 return $saved; |
378 '3.5.0', |
342 } |
379 'wp_save_image_editor_file' |
343 |
380 ); |
344 return $image->save( $filename, $mime_type ); |
|
345 } else { |
|
346 _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) ); |
|
347 |
|
348 /** This filter is documented in wp-admin/includes/image-edit.php */ |
|
349 $image = apply_filters( 'image_save_pre', $image, $post_id ); |
|
350 |
|
351 /** |
|
352 * Filters whether to skip saving the image file. |
|
353 * |
|
354 * Returning a non-null value will short-circuit the save method, |
|
355 * returning that value instead. |
|
356 * |
|
357 * @since 2.9.0 |
|
358 * @deprecated 3.5.0 Use wp_save_image_editor_file instead. |
|
359 * |
|
360 * @param mixed $override Value to return instead of saving. Default null. |
|
361 * @param string $filename Name of the file to be saved. |
|
362 * @param WP_Image_Editor $image WP_Image_Editor instance. |
|
363 * @param string $mime_type Image mime type. |
|
364 * @param int $post_id Post ID. |
|
365 */ |
|
366 $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); |
|
367 |
381 |
368 if ( null !== $saved ) { |
382 if ( null !== $saved ) { |
369 return $saved; |
383 return $saved; |
370 } |
384 } |
371 |
385 |