92 /** |
92 /** |
93 * {@internal Missing Short Description}} |
93 * {@internal Missing Short Description}} |
94 * |
94 * |
95 * @since 2.5.0 |
95 * @since 2.5.0 |
96 * |
96 * |
97 * @param unknown_type $id |
97 * @param integer $id image attachment id |
98 * @param unknown_type $alt |
98 * @param string $caption image caption |
99 * @param unknown_type $title |
99 * @param string $alt image alt attribute |
100 * @param unknown_type $align |
100 * @param string $title image title attribute |
101 * @param unknown_type $url |
101 * @param string $align image css alignment property |
102 * @param unknown_type $rel |
102 * @param string $url image src url |
103 * @param unknown_type $size |
103 * @param string|bool $rel image rel attribute |
104 * @return unknown |
104 * @param string $size image size (thumbnail, medium, large, full or added with add_image_size() ) |
|
105 * @return string the html to insert into editor |
105 */ |
106 */ |
106 function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') { |
107 function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') { |
107 |
108 |
108 $html = get_image_tag($id, $alt, $title, $align, $size); |
109 $html = get_image_tag($id, $alt, '', $align, $size); |
109 |
110 |
110 $rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : ''; |
111 $rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : ''; |
111 |
112 |
112 if ( $url ) |
113 if ( $url ) |
113 $html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>"; |
114 $html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>"; |
116 |
117 |
117 return $html; |
118 return $html; |
118 } |
119 } |
119 |
120 |
120 /** |
121 /** |
121 * {@internal Missing Short Description}} |
122 * Adds image shortcode with caption to editor |
122 * |
123 * |
123 * @since 2.6.0 |
124 * @since 2.6.0 |
124 * |
125 * |
125 * @param unknown_type $html |
126 * @param string $html |
126 * @param unknown_type $id |
127 * @param integer $id |
127 * @param unknown_type $alt |
128 * @param string $caption image caption |
128 * @param unknown_type $title |
129 * @param string $alt image alt attribute |
129 * @param unknown_type $align |
130 * @param string $title image title attribute |
130 * @param unknown_type $url |
131 * @param string $align image css alignment property |
131 * @param unknown_type $size |
132 * @param string $url image src url |
132 * @return unknown |
133 * @param string $size image size (thumbnail, medium, large, full or added with add_image_size() ) |
|
134 * @return string |
133 */ |
135 */ |
134 function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { |
136 function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { |
135 |
137 |
136 if ( empty($caption) || apply_filters( 'disable_captions', '' ) ) |
138 if ( empty($caption) || apply_filters( 'disable_captions', '' ) ) |
137 return $html; |
139 return $html; |
267 * @return int|object The ID of the attachment or a WP_Error on failure |
267 * @return int|object The ID of the attachment or a WP_Error on failure |
268 */ |
268 */ |
269 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { |
269 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { |
270 $overrides = array('test_form'=>false); |
270 $overrides = array('test_form'=>false); |
271 |
271 |
272 $file = wp_handle_sideload($file_array, $overrides); |
272 $time = current_time( 'mysql' ); |
|
273 if ( $post = get_post( $post_id ) ) { |
|
274 if ( substr( $post->post_date, 0, 4 ) > 0 ) |
|
275 $time = $post->post_date; |
|
276 } |
|
277 |
|
278 $file = wp_handle_sideload( $file_array, $overrides, $time ); |
273 if ( isset($file['error']) ) |
279 if ( isset($file['error']) ) |
274 return new WP_Error( 'upload_error', $file['error'] ); |
280 return new WP_Error( 'upload_error', $file['error'] ); |
275 |
281 |
276 $url = $file['url']; |
282 $url = $file['url']; |
277 $type = $file['type']; |
283 $type = $file['type']; |
371 </html> |
374 </html> |
372 <?php |
375 <?php |
373 } |
376 } |
374 |
377 |
375 /** |
378 /** |
376 * {@internal Missing Short Description}} |
379 * Adds the media button to the editor |
377 * |
380 * |
378 * @since 2.5.0 |
381 * @since 2.5.0 |
|
382 * |
|
383 * @param string $editor_id |
379 */ |
384 */ |
380 function media_buttons($editor_id = 'content') { |
385 function media_buttons($editor_id = 'content') { |
381 $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); |
386 $post = get_post(); |
382 |
387 if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) |
383 $img = '<img src="' . esc_url( admin_url( 'images/media-button.png?ver=20111005' ) ) . '" width="15" height="15" />'; |
388 $post = $GLOBALS['post_ID']; |
384 |
389 |
385 echo '<a href="' . esc_url( get_upload_iframe_src() ) . '" class="thickbox add_media" id="' . esc_attr( $editor_id ) . '-add_media" title="' . esc_attr__( 'Add Media' ) . '" onclick="return false;">' . sprintf( $context, $img ) . '</a>'; |
390 wp_enqueue_media( array( |
|
391 'post' => $post |
|
392 ) ); |
|
393 |
|
394 $img = '<span class="wp-media-buttons-icon"></span> '; |
|
395 |
|
396 echo '<a href="#" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>'; |
|
397 |
|
398 // Don't use this filter. Want to add a button? Use the media_buttons action. |
|
399 $legacy_filter = apply_filters('media_buttons_context', ''); // deprecated |
|
400 |
|
401 if ( $legacy_filter ) { |
|
402 // #WP22559. Close <a> if a plugin started by closing <a> to open their own <a> tag. |
|
403 if ( 0 === stripos( trim( $legacy_filter ), '</a>' ) ) |
|
404 $legacy_filter .= '</a>'; |
|
405 echo $legacy_filter; |
|
406 } |
386 } |
407 } |
387 add_action( 'media_buttons', 'media_buttons' ); |
408 add_action( 'media_buttons', 'media_buttons' ); |
388 |
|
389 function _media_button($title, $icon, $type, $id) { |
|
390 return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='{$id}-add_{$type}' class='thickbox add_$type' title='" . esc_attr( $title ) . "'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' onclick='return false;' /></a>"; |
|
391 } |
|
392 |
409 |
393 function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { |
410 function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { |
394 global $post_ID; |
411 global $post_ID; |
395 |
412 |
396 if ( empty( $post_id ) ) |
413 if ( empty( $post_id ) ) |
796 /** |
813 /** |
797 * {@internal Missing Short Description}} |
814 * {@internal Missing Short Description}} |
798 * |
815 * |
799 * @since 2.5.0 |
816 * @since 2.5.0 |
800 * |
817 * |
801 * @param unknown_type $form_fields |
818 * @param array $form_fields |
802 * @param unknown_type $post |
819 * @param object $post |
803 * @return unknown |
820 * @return array |
804 */ |
821 */ |
805 function image_attachment_fields_to_edit($form_fields, $post) { |
822 function image_attachment_fields_to_edit($form_fields, $post) { |
806 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
|
807 $alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true); |
|
808 if ( empty($alt) ) |
|
809 $alt = ''; |
|
810 |
|
811 $form_fields['post_title']['required'] = true; |
|
812 |
|
813 $form_fields['image_alt'] = array( |
|
814 'value' => $alt, |
|
815 'label' => __('Alternate Text'), |
|
816 'helps' => __('Alt text for the image, e.g. “The Mona Lisa”') |
|
817 ); |
|
818 |
|
819 $form_fields['align'] = array( |
|
820 'label' => __('Alignment'), |
|
821 'input' => 'html', |
|
822 'html' => image_align_input_fields($post, get_option('image_default_align')), |
|
823 ); |
|
824 |
|
825 $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); |
|
826 |
|
827 } else { |
|
828 unset( $form_fields['image_alt'] ); |
|
829 } |
|
830 return $form_fields; |
823 return $form_fields; |
831 } |
824 } |
832 |
825 |
833 add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); |
|
834 |
|
835 /** |
826 /** |
836 * {@internal Missing Short Description}} |
827 * {@internal Missing Short Description}} |
837 * |
828 * |
838 * @since 2.5.0 |
829 * @since 2.5.0 |
839 * |
830 * |
840 * @param unknown_type $form_fields |
831 * @param array $form_fields |
841 * @param unknown_type $post |
832 * @param object $post {@internal $post not used}} |
842 * @return unknown |
833 * @return array |
843 */ |
834 */ |
844 function media_single_attachment_fields_to_edit( $form_fields, $post ) { |
835 function media_single_attachment_fields_to_edit( $form_fields, $post ) { |
845 unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); |
836 unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); |
846 return $form_fields; |
837 return $form_fields; |
847 } |
838 } |
849 /** |
840 /** |
850 * {@internal Missing Short Description}} |
841 * {@internal Missing Short Description}} |
851 * |
842 * |
852 * @since 2.8.0 |
843 * @since 2.8.0 |
853 * |
844 * |
854 * @param unknown_type $form_fields |
845 * @param array $form_fields |
855 * @param unknown_type $post |
846 * @param object $post {@internal $post not used}} |
856 * @return unknown |
847 * @return array |
857 */ |
848 */ |
858 function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { |
849 function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { |
859 unset($form_fields['image_url']); |
850 unset($form_fields['image_url']); |
860 return $form_fields; |
851 return $form_fields; |
861 } |
852 } |
862 |
853 |
863 /** |
854 /** |
864 * {@internal Missing Short Description}} |
855 * Filters input from media_upload_form_handler() and assigns a default |
|
856 * post_title from the file name if none supplied. |
|
857 * |
|
858 * Illustrates the use of the attachment_fields_to_save filter |
|
859 * which can be used to add default values to any field before saving to DB. |
865 * |
860 * |
866 * @since 2.5.0 |
861 * @since 2.5.0 |
867 * |
862 * |
868 * @param unknown_type $post |
863 * @param object $post |
869 * @param unknown_type $attachment |
864 * @param array $attachment {@internal $attachment not used}} |
870 * @return unknown |
865 * @return array |
871 */ |
866 */ |
872 function image_attachment_fields_to_save($post, $attachment) { |
867 function image_attachment_fields_to_save($post, $attachment) { |
873 if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { |
868 if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { |
874 if ( strlen(trim($post['post_title'])) == 0 ) { |
869 if ( strlen(trim($post['post_title'])) == 0 ) { |
875 $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); |
870 $post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); |
885 /** |
880 /** |
886 * {@internal Missing Short Description}} |
881 * {@internal Missing Short Description}} |
887 * |
882 * |
888 * @since 2.5.0 |
883 * @since 2.5.0 |
889 * |
884 * |
890 * @param unknown_type $html |
885 * @param string $html |
891 * @param unknown_type $attachment_id |
886 * @param integer $attachment_id |
892 * @param unknown_type $attachment |
887 * @param array $attachment |
893 * @return unknown |
888 * @return array |
894 */ |
889 */ |
895 function image_media_send_to_editor($html, $attachment_id, $attachment) { |
890 function image_media_send_to_editor($html, $attachment_id, $attachment) { |
896 $post =& get_post($attachment_id); |
891 $post = get_post($attachment_id); |
897 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
892 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
898 $url = $attachment['url']; |
893 $url = $attachment['url']; |
899 $align = !empty($attachment['align']) ? $attachment['align'] : 'none'; |
894 $align = !empty($attachment['align']) ? $attachment['align'] : 'none'; |
900 $size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium'; |
895 $size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium'; |
901 $alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : ''; |
896 $alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : ''; |
963 ) |
958 ) |
964 ); |
959 ); |
965 |
960 |
966 foreach ( get_attachment_taxonomies($post) as $taxonomy ) { |
961 foreach ( get_attachment_taxonomies($post) as $taxonomy ) { |
967 $t = (array) get_taxonomy($taxonomy); |
962 $t = (array) get_taxonomy($taxonomy); |
968 if ( ! $t['public'] ) |
963 if ( ! $t['public'] || ! $t['show_ui'] ) |
969 continue; |
964 continue; |
970 if ( empty($t['label']) ) |
965 if ( empty($t['label']) ) |
971 $t['label'] = $taxonomy; |
966 $t['label'] = $taxonomy; |
972 if ( empty($t['args']) ) |
967 if ( empty($t['args']) ) |
973 $t['args'] = array(); |
968 $t['args'] = array(); |
974 |
969 |
975 $terms = get_object_term_cache($post->ID, $taxonomy); |
970 $terms = get_object_term_cache($post->ID, $taxonomy); |
976 if ( empty($terms) ) |
971 if ( false === $terms ) |
977 $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
972 $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
978 |
973 |
979 $values = array(); |
974 $values = array(); |
980 |
975 |
981 foreach ( $terms as $term ) |
976 foreach ( $terms as $term ) |
982 $values[] = $term->name; |
977 $values[] = $term->slug; |
983 $t['value'] = join(', ', $values); |
978 $t['value'] = join(', ', $values); |
984 |
979 |
985 $form_fields[$taxonomy] = $t; |
980 $form_fields[$taxonomy] = $t; |
986 } |
981 } |
987 |
982 |
988 // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default |
983 // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default |
989 // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) |
984 // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) |
990 $form_fields = array_merge_recursive($form_fields, (array) $errors); |
985 $form_fields = array_merge_recursive($form_fields, (array) $errors); |
|
986 |
|
987 // This was formerly in image_attachment_fields_to_edit(). |
|
988 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
|
989 $alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true); |
|
990 if ( empty($alt) ) |
|
991 $alt = ''; |
|
992 |
|
993 $form_fields['post_title']['required'] = true; |
|
994 |
|
995 $form_fields['image_alt'] = array( |
|
996 'value' => $alt, |
|
997 'label' => __('Alternative Text'), |
|
998 'helps' => __('Alt text for the image, e.g. “The Mona Lisa”') |
|
999 ); |
|
1000 |
|
1001 $form_fields['align'] = array( |
|
1002 'label' => __('Alignment'), |
|
1003 'input' => 'html', |
|
1004 'html' => image_align_input_fields($post, get_option('image_default_align')), |
|
1005 ); |
|
1006 |
|
1007 $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); |
|
1008 |
|
1009 } else { |
|
1010 unset( $form_fields['image_alt'] ); |
|
1011 } |
991 |
1012 |
992 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); |
1013 $form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); |
993 |
1014 |
994 return $form_fields; |
1015 return $form_fields; |
995 } |
1016 } |
1109 if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) |
1130 if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) |
1110 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; |
1131 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; |
1111 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); |
1132 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); |
1112 |
1133 |
1113 $image_edit_button = ''; |
1134 $image_edit_button = ''; |
1114 if ( gd_edit_image_support( $post->post_mime_type ) ) { |
1135 if ( wp_attachment_is_image( $post->ID ) && wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { |
1115 $nonce = wp_create_nonce( "image_editor-$post->ID" ); |
1136 $nonce = wp_create_nonce( "image_editor-$post->ID" ); |
1116 $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <img src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' class='imgedit-wait-spin' alt='' />"; |
1137 $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>"; |
1117 } |
1138 } |
1118 |
1139 |
1119 $attachment_url = get_permalink( $attachment_id ); |
1140 $attachment_url = get_permalink( $attachment_id ); |
1120 |
1141 |
1121 $item = " |
1142 $item = " |
1154 |
1175 |
1155 if ( $send ) |
1176 if ( $send ) |
1156 $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); |
1177 $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); |
1157 if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { |
1178 if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { |
1158 if ( !EMPTY_TRASH_DAYS ) { |
1179 if ( !EMPTY_TRASH_DAYS ) { |
1159 $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>'; |
1180 $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>'; |
1160 } elseif ( !MEDIA_TRASH ) { |
1181 } elseif ( !MEDIA_TRASH ) { |
1161 $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> |
1182 $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> |
1162 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p> |
1183 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p> |
1163 <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> |
1184 <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> |
1164 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> |
1185 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> |
1165 </div>"; |
1186 </div>"; |
1166 } else { |
1187 } else { |
1167 $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> |
1188 $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> |
1168 <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; |
1189 <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-post_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; |
1169 } |
1190 } |
1170 } else { |
1191 } else { |
1171 $delete = ''; |
1192 $delete = ''; |
1172 } |
1193 } |
1173 |
1194 |
1258 } |
1279 } |
1259 |
1280 |
1260 return $item; |
1281 return $item; |
1261 } |
1282 } |
1262 |
1283 |
|
1284 function get_compat_media_markup( $attachment_id, $args = null ) { |
|
1285 $post = get_post( $attachment_id ); |
|
1286 |
|
1287 $default_args = array( |
|
1288 'errors' => null, |
|
1289 'in_modal' => false, |
|
1290 ); |
|
1291 |
|
1292 $user_can_edit = current_user_can( 'edit_post', $attachment_id ); |
|
1293 |
|
1294 $args = wp_parse_args( $args, $default_args ); |
|
1295 $args = apply_filters( 'get_media_item_args', $args ); |
|
1296 |
|
1297 $form_fields = array(); |
|
1298 |
|
1299 if ( $args['in_modal'] ) { |
|
1300 foreach ( get_attachment_taxonomies($post) as $taxonomy ) { |
|
1301 $t = (array) get_taxonomy($taxonomy); |
|
1302 if ( ! $t['public'] || ! $t['show_ui'] ) |
|
1303 continue; |
|
1304 if ( empty($t['label']) ) |
|
1305 $t['label'] = $taxonomy; |
|
1306 if ( empty($t['args']) ) |
|
1307 $t['args'] = array(); |
|
1308 |
|
1309 $terms = get_object_term_cache($post->ID, $taxonomy); |
|
1310 if ( false === $terms ) |
|
1311 $terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
|
1312 |
|
1313 $values = array(); |
|
1314 |
|
1315 foreach ( $terms as $term ) |
|
1316 $values[] = $term->slug; |
|
1317 $t['value'] = join(', ', $values); |
|
1318 $t['taxonomy'] = true; |
|
1319 |
|
1320 $form_fields[$taxonomy] = $t; |
|
1321 } |
|
1322 } |
|
1323 |
|
1324 // Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default |
|
1325 // The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) |
|
1326 $form_fields = array_merge_recursive($form_fields, (array) $args['errors'] ); |
|
1327 |
|
1328 $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); |
|
1329 |
|
1330 unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], |
|
1331 $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], |
|
1332 $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); |
|
1333 |
|
1334 $media_meta = apply_filters( 'media_meta', '', $post ); |
|
1335 |
|
1336 $defaults = array( |
|
1337 'input' => 'text', |
|
1338 'required' => false, |
|
1339 'value' => '', |
|
1340 'extra_rows' => array(), |
|
1341 'show_in_edit' => true, |
|
1342 'show_in_modal' => true, |
|
1343 ); |
|
1344 |
|
1345 $hidden_fields = array(); |
|
1346 |
|
1347 $item = ''; |
|
1348 foreach ( $form_fields as $id => $field ) { |
|
1349 if ( $id[0] == '_' ) |
|
1350 continue; |
|
1351 |
|
1352 $name = "attachments[$attachment_id][$id]"; |
|
1353 $id_attr = "attachments-$attachment_id-$id"; |
|
1354 |
|
1355 if ( !empty( $field['tr'] ) ) { |
|
1356 $item .= $field['tr']; |
|
1357 continue; |
|
1358 } |
|
1359 |
|
1360 $field = array_merge( $defaults, $field ); |
|
1361 |
|
1362 if ( ( ! $field['show_in_edit'] && ! $args['in_modal'] ) || ( ! $field['show_in_modal'] && $args['in_modal'] ) ) |
|
1363 continue; |
|
1364 |
|
1365 if ( $field['input'] == 'hidden' ) { |
|
1366 $hidden_fields[$name] = $field['value']; |
|
1367 continue; |
|
1368 } |
|
1369 |
|
1370 $readonly = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : ''; |
|
1371 $required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : ''; |
|
1372 $aria_required = $field['required'] ? " aria-required='true' " : ''; |
|
1373 $class = 'compat-field-' . $id; |
|
1374 $class .= $field['required'] ? ' form-required' : ''; |
|
1375 |
|
1376 $item .= "\t\t<tr class='$class'>"; |
|
1377 $item .= "\t\t\t<th valign='top' scope='row' class='label'><label for='$id_attr'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label>"; |
|
1378 $item .= "</th>\n\t\t\t<td class='field'>"; |
|
1379 |
|
1380 if ( !empty( $field[ $field['input'] ] ) ) |
|
1381 $item .= $field[ $field['input'] ]; |
|
1382 elseif ( $field['input'] == 'textarea' ) { |
|
1383 if ( 'post_content' == $id && user_can_richedit() ) { |
|
1384 // sanitize_post() skips the post_content when user_can_richedit |
|
1385 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); |
|
1386 } |
|
1387 $item .= "<textarea id='$id_attr' name='$name' $aria_required>" . $field['value'] . '</textarea>'; |
|
1388 } else { |
|
1389 $item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly $aria_required />"; |
|
1390 } |
|
1391 if ( !empty( $field['helps'] ) ) |
|
1392 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; |
|
1393 $item .= "</td>\n\t\t</tr>\n"; |
|
1394 |
|
1395 $extra_rows = array(); |
|
1396 |
|
1397 if ( !empty( $field['errors'] ) ) |
|
1398 foreach ( array_unique( (array) $field['errors'] ) as $error ) |
|
1399 $extra_rows['error'][] = $error; |
|
1400 |
|
1401 if ( !empty( $field['extra_rows'] ) ) |
|
1402 foreach ( $field['extra_rows'] as $class => $rows ) |
|
1403 foreach ( (array) $rows as $html ) |
|
1404 $extra_rows[$class][] = $html; |
|
1405 |
|
1406 foreach ( $extra_rows as $class => $rows ) |
|
1407 foreach ( $rows as $html ) |
|
1408 $item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n"; |
|
1409 } |
|
1410 |
|
1411 if ( !empty( $form_fields['_final'] ) ) |
|
1412 $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; |
|
1413 if ( $item ) |
|
1414 $item = '<table class="compat-attachment-fields">' . $item . '</table>'; |
|
1415 |
|
1416 foreach ( $hidden_fields as $hidden_field => $value ) { |
|
1417 $item .= '<input type="hidden" name="' . esc_attr( $hidden_field ) . '" value="' . esc_attr( $value ) . '" />' . "\n"; |
|
1418 } |
|
1419 |
|
1420 return array( |
|
1421 'item' => $item, |
|
1422 'meta' => $media_meta, |
|
1423 ); |
|
1424 } |
|
1425 |
1263 /** |
1426 /** |
1264 * {@internal Missing Short Description}} |
1427 * {@internal Missing Short Description}} |
1265 * |
1428 * |
1266 * @since 2.5.0 |
1429 * @since 2.5.0 |
1267 */ |
1430 */ |
1268 function media_upload_header() { |
1431 function media_upload_header() { |
1269 ?> |
1432 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; |
1270 <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script> |
1433 echo '<script type="text/javascript">post_id = ' . $post_id . ";</script>\n"; |
1271 <div id="media-upload-header"> |
1434 if ( empty( $_GET['chromeless'] ) ) { |
1272 <?php the_media_upload_tabs(); ?> |
1435 echo '<div id="media-upload-header">'; |
1273 </div> |
1436 the_media_upload_tabs(); |
1274 <?php |
1437 echo '</div>'; |
|
1438 } |
1275 } |
1439 } |
1276 |
1440 |
1277 /** |
1441 /** |
1278 * {@internal Missing Short Description}} |
1442 * {@internal Missing Short Description}} |
1279 * |
1443 * |
1474 /** |
1642 /** |
1475 * {@internal Missing Short Description}} |
1643 * {@internal Missing Short Description}} |
1476 * |
1644 * |
1477 * @since 2.7.0 |
1645 * @since 2.7.0 |
1478 * |
1646 * |
1479 * @param unknown_type $type |
1647 * @param string $type |
1480 * @param unknown_type $errors |
1648 * @param object $errors |
1481 * @param unknown_type $id |
1649 * @param integer $id |
1482 */ |
1650 */ |
1483 function media_upload_type_url_form($type = null, $errors = null, $id = null) { |
1651 function media_upload_type_url_form($type = null, $errors = null, $id = null) { |
1484 if ( null === $type ) |
1652 if ( null === $type ) |
1485 $type = 'image'; |
1653 $type = 'image'; |
1486 |
1654 |
1487 media_upload_header(); |
1655 media_upload_header(); |
1488 |
1656 |
1489 $post_id = intval($_REQUEST['post_id']); |
1657 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; |
1490 |
1658 |
1491 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
1659 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
1492 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
1660 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
1493 $form_class = 'media-upload-form type-form validate'; |
1661 $form_class = 'media-upload-form type-form validate'; |
1494 |
1662 |
1513 insert : function() { |
1681 insert : function() { |
1514 var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = ''; |
1682 var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = ''; |
1515 |
1683 |
1516 if ( '' == f.src.value || '' == t.width ) |
1684 if ( '' == f.src.value || '' == t.width ) |
1517 return false; |
1685 return false; |
1518 |
|
1519 if ( f.title.value ) { |
|
1520 title = f.title.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
|
1521 title = ' title="'+title+'"'; |
|
1522 } |
|
1523 |
1686 |
1524 if ( f.alt.value ) |
1687 if ( f.alt.value ) |
1525 alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
1688 alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
1526 |
1689 |
1527 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> |
1690 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> |
1757 /** |
1920 /** |
1758 * {@internal Missing Short Description}} |
1921 * {@internal Missing Short Description}} |
1759 * |
1922 * |
1760 * @since 2.5.0 |
1923 * @since 2.5.0 |
1761 * |
1924 * |
1762 * @param unknown_type $errors |
1925 * @param array $errors |
1763 */ |
1926 */ |
1764 function media_upload_library_form($errors) { |
1927 function media_upload_library_form($errors) { |
1765 global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; |
1928 global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; |
1766 |
1929 |
1767 media_upload_header(); |
1930 media_upload_header(); |
1768 |
1931 |
1769 $post_id = intval($_REQUEST['post_id']); |
1932 $post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; |
1770 |
1933 |
1771 $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id"); |
1934 $form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id"); |
1772 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
1935 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
1773 $form_class = 'media-upload-form validate'; |
1936 $form_class = 'media-upload-form validate'; |
1774 |
1937 |
1956 return ' |
2120 return ' |
1957 <p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p> |
2121 <p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p> |
1958 <table class="describe ' . $table_class . '"><tbody> |
2122 <table class="describe ' . $table_class . '"><tbody> |
1959 <tr> |
2123 <tr> |
1960 <th valign="top" scope="row" class="label" style="width:130px;"> |
2124 <th valign="top" scope="row" class="label" style="width:130px;"> |
1961 <span class="alignleft"><label for="src">' . __('URL') . '</label></span> |
2125 <label for="src"><span class="alignleft">' . __('URL') . '</span></label> |
1962 <span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span> |
2126 <span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span> |
1963 </th> |
2127 </th> |
1964 <td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td> |
2128 <td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td> |
1965 </tr> |
2129 </tr> |
1966 |
2130 |
1967 <tr> |
2131 <tr> |
1968 <th valign="top" scope="row" class="label"> |
2132 <th valign="top" scope="row" class="label"> |
1969 <span class="alignleft"><label for="title">' . __('Title') . '</label></span> |
2133 <label for="title"><span class="alignleft">' . __('Title') . '</span></label> |
1970 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
2134 <span class="alignright"><abbr title="required" class="required">*</abbr></span> |
1971 </th> |
2135 </th> |
1972 <td class="field"><input id="title" name="title" value="" type="text" aria-required="true" /></td> |
2136 <td class="field"><input id="title" name="title" value="" type="text" aria-required="true" /></td> |
1973 </tr> |
2137 </tr> |
1974 |
2138 |
1975 <tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</p></td></tr> |
2139 <tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</p></td></tr> |
1976 |
2140 |
1977 <tr class="image-only"> |
2141 <tr class="image-only"> |
1978 <th valign="top" scope="row" class="label"> |
2142 <th valign="top" scope="row" class="label"> |
1979 <span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span> |
2143 <label for="alt"><span class="alignleft">' . __('Alternative Text') . '</span></label> |
1980 </th> |
2144 </th> |
1981 <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" /> |
2145 <td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" /> |
1982 <p class="help">' . __('Alt text for the image, e.g. “The Mona Lisa”') . '</p></td> |
2146 <p class="help">' . __('Alt text for the image, e.g. “The Mona Lisa”') . '</p></td> |
1983 </tr> |
2147 </tr> |
1984 ' . $caption . ' |
2148 ' . $caption . ' |
2021 </tbody></table> |
2185 </tbody></table> |
2022 '; |
2186 '; |
2023 |
2187 |
2024 } |
2188 } |
2025 |
2189 |
2026 function _insert_into_post_button($type) { |
2190 /** |
2027 if ( !post_type_supports(get_post_type($_GET['post_id']), 'editor') ) |
2191 * Displays the multi-file uploader message. |
2028 return ''; |
|
2029 |
|
2030 if ( 'image' == $type ) |
|
2031 return ' |
|
2032 <tr> |
|
2033 <td></td> |
|
2034 <td> |
|
2035 <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" /> |
|
2036 </td> |
|
2037 </tr> |
|
2038 '; |
|
2039 |
|
2040 return ' |
|
2041 <tr> |
|
2042 <td></td> |
|
2043 <td> |
|
2044 ' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . ' |
|
2045 </td> |
|
2046 </tr> |
|
2047 '; |
|
2048 } |
|
2049 |
|
2050 /** |
|
2051 * {@internal Missing Short Description}} |
|
2052 * |
2192 * |
2053 * @since 2.6.0 |
2193 * @since 2.6.0 |
2054 */ |
2194 */ |
2055 function media_upload_flash_bypass() { |
2195 function media_upload_flash_bypass() { |
|
2196 $browser_uploader = admin_url( 'media-new.php?browser-uploader' ); |
|
2197 |
|
2198 if ( $post = get_post() ) |
|
2199 $browser_uploader .= '&post_id=' . intval( $post->ID ); |
|
2200 elseif ( ! empty( $GLOBALS['post_ID'] ) ) |
|
2201 $browser_uploader .= '&post_id=' . intval( $GLOBALS['post_ID'] ); |
|
2202 |
2056 ?> |
2203 ?> |
2057 <p class="upload-flash-bypass"> |
2204 <p class="upload-flash-bypass"> |
2058 <?php _e('You are using the multi-file uploader. Problems? Try the <a href="#">browser uploader</a> instead.'); ?> |
2205 <?php printf( __( 'You are using the multi-file uploader. Problems? Try the <a href="%1$s" target="%2$s">browser uploader</a> instead.' ), $browser_uploader, '_blank' ); ?> |
2059 </p> |
2206 </p> |
2060 <?php |
2207 <?php |
2061 } |
2208 } |
2062 add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
2209 add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
2063 |
2210 |
2064 /** |
2211 /** |
2065 * {@internal Missing Short Description}} |
2212 * Displays the browser's built-in uploader message. |
2066 * |
2213 * |
2067 * @since 2.6.0 |
2214 * @since 2.6.0 |
2068 */ |
2215 */ |
2069 function media_upload_html_bypass() { |
2216 function media_upload_html_bypass() { |
2070 ?> |
2217 ?> |
2104 ?> |
2251 ?> |
2105 </label></p> |
2252 </label></p> |
2106 <?php |
2253 <?php |
2107 } |
2254 } |
2108 |
2255 |
|
2256 /** |
|
2257 * Displays the out of storage quota message in Multisite. |
|
2258 * |
|
2259 * @since 3.5.0 |
|
2260 */ |
|
2261 function multisite_over_quota_message() { |
|
2262 echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>'; |
|
2263 } |
|
2264 |
|
2265 /** |
|
2266 * Displays the image and editor in the post editor |
|
2267 * |
|
2268 * @since 3.5.0 |
|
2269 */ |
|
2270 function edit_form_image_editor() { |
|
2271 $post = get_post(); |
|
2272 |
|
2273 $open = isset( $_GET['image-editor'] ); |
|
2274 if ( $open ) |
|
2275 require_once ABSPATH . 'wp-admin/includes/image-edit.php'; |
|
2276 |
|
2277 $thumb_url = false; |
|
2278 if ( $attachment_id = intval( $post->ID ) ) |
|
2279 $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true ); |
|
2280 |
|
2281 $filename = esc_html( basename( $post->guid ) ); |
|
2282 $title = esc_attr( $post->post_title ); |
|
2283 $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); |
|
2284 |
|
2285 $att_url = wp_get_attachment_url( $post->ID ); |
|
2286 |
|
2287 if ( wp_attachment_is_image( $post->ID ) ) : |
|
2288 $image_edit_button = ''; |
|
2289 if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { |
|
2290 $nonce = wp_create_nonce( "image_editor-$post->ID" ); |
|
2291 $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>"; |
|
2292 } |
|
2293 ?> |
|
2294 <div class="wp_attachment_holder"> |
|
2295 <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div> |
|
2296 |
|
2297 <div<?php if ( $open ) echo ' style="display:none"'; ?> class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>"> |
|
2298 <p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" /></p> |
|
2299 <p><?php echo $image_edit_button; ?></p> |
|
2300 </div> |
|
2301 <div<?php if ( ! $open ) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"> |
|
2302 <?php if ( $open ) wp_image_editor( $attachment_id ); ?> |
|
2303 </div> |
|
2304 </div> |
|
2305 <?php endif; ?> |
|
2306 |
|
2307 <div class="wp_attachment_details"> |
|
2308 <p> |
|
2309 <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br /> |
|
2310 <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea> |
|
2311 </p> |
|
2312 |
|
2313 <?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?> |
|
2314 <p> |
|
2315 <label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br /> |
|
2316 <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" /> |
|
2317 </p> |
|
2318 <?php endif; ?> |
|
2319 |
|
2320 <?php |
|
2321 $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); |
|
2322 $editor_args = array( |
|
2323 'textarea_name' => 'content', |
|
2324 'textarea_rows' => 5, |
|
2325 'media_buttons' => false, |
|
2326 'tinymce' => false, |
|
2327 'quicktags' => $quicktags_settings, |
|
2328 ); |
|
2329 ?> |
|
2330 |
|
2331 <label for="content"><strong><?php _e( 'Description' ); ?></strong></label> |
|
2332 <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?> |
|
2333 |
|
2334 </div> |
|
2335 <?php |
|
2336 $extras = get_compat_media_markup( $post->ID ); |
|
2337 echo $extras['item']; |
|
2338 echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n"; |
|
2339 } |
|
2340 |
|
2341 /** |
|
2342 * Displays non-editable attachment metadata in the publish metabox |
|
2343 * |
|
2344 * @since 3.5.0 |
|
2345 */ |
|
2346 function attachment_submitbox_metadata() { |
|
2347 $post = get_post(); |
|
2348 |
|
2349 $filename = esc_html( basename( $post->guid ) ); |
|
2350 |
|
2351 $media_dims = ''; |
|
2352 $meta = wp_get_attachment_metadata( $post->ID ); |
|
2353 if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) |
|
2354 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; |
|
2355 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); |
|
2356 |
|
2357 $att_url = wp_get_attachment_url( $post->ID ); |
|
2358 ?> |
|
2359 <div class="misc-pub-section"> |
|
2360 <label for="attachment_url"><?php _e( 'File URL:' ); ?></label> |
|
2361 <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /> |
|
2362 </div> |
|
2363 <div class="misc-pub-section"> |
|
2364 <?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong> |
|
2365 </div> |
|
2366 <div class="misc-pub-section"> |
|
2367 <?php _e( 'File type:' ); ?> <strong><?php |
|
2368 if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) |
|
2369 echo esc_html( strtoupper( $matches[1] ) ); |
|
2370 else |
|
2371 echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); |
|
2372 ?></strong> |
|
2373 </div> |
|
2374 |
|
2375 <?php if ( $media_dims ) : ?> |
|
2376 <div class="misc-pub-section"> |
|
2377 <?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong> |
|
2378 </div> |
|
2379 <?php |
|
2380 endif; |
|
2381 } |
|
2382 |
2109 add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
2383 add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
2110 add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
2384 add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
2111 add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
2385 add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
2112 add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
2386 add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
2113 |
2387 |