Consolidate post_mime_type code. props scribu. fixes #10992

git-svn-id: https://develop.svn.wordpress.org/trunk@12110 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2009-10-26 17:56:28 +00:00
parent ba1f1d3780
commit a556c8ce89
3 changed files with 24 additions and 20 deletions
+5 -7
View File
@@ -1105,7 +1105,7 @@ function get_media_items( $post_id, $errors ) {
* @return string HTML form for attachment.
*/
function get_media_item( $attachment_id, $args = null ) {
global $post_mime_types, $redir_tab;
global $redir_tab;
if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
$thumb_url = $thumb_url[0];
@@ -1130,12 +1130,10 @@ function get_media_item( $attachment_id, $args = null ) {
$tags = esc_attr(join(', ', $tags));
}
$type = '';
if ( isset($post_mime_types) ) {
$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
$type = array_shift($keys);
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
}
$post_mime_types = get_post_mime_types();
$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
$type = array_shift($keys);
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
$form_fields = get_attachment_fields_to_edit($post, $errors);