__('From Computer'), // handler action suffix => tab text 'attachments' => __('Attachments'), 'library' => __('Media Library'), ); return apply_filters('media_upload_tabs', $_default_tabs); } function update_attachments_tab($tabs) { global $wpdb; if ( !isset($_REQUEST['post_id']) ) { unset($tabs['attachments']); return $tabs; } if ( intval($_REQUEST['post_id']) ) $attachments = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id'])); $tabs['attachments'] = sprintf(__('Attachments (%s)'), "$attachments"); return $tabs; } add_filter('media_upload_tabs', 'update_attachments_tab'); function the_media_upload_tabs() { $tabs = media_upload_tabs(); if ( !empty($tabs) ) { echo "
\n"; } } function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { $html = get_image_tag($id, $alt, $title, $align, $rel, $size); $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; if ( $url ) $html = "$html"; elseif ( $size == 'thumb' || $size == 'medium' ) $html = ''.$html.''; $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); return $html; } function media_send_to_editor($html) { ?> false); $file = wp_handle_upload($_FILES[$file_id], $overrides); if ( isset($file['error']) ) return new wp_error( 'upload_error', $file['error'] ); $url = $file['url']; $type = $file['type']; $file = $file['file']; $title = preg_replace('/\.[^.]+$/', '', basename($file)); $content = ''; // use image exif/iptc data for title and caption defaults if possible if ( $image_meta = @wp_read_image_metadata($file) ) { if ( trim($image_meta['title']) ) $title = $image_meta['title']; if ( trim($image_meta['caption']) ) $content = $image_meta['caption']; } // Construct the attachment array $attachment = array_merge( array( 'post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => $content, ), $post_data ); // Save the data $id = wp_insert_attachment($attachment, $file, $post_parent); if ( !is_wp_error($id) ) { wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); } return $id; } // wrap iframe content (produced by $content_func) in a doctype, html head/body etc // any additional function args will be passed to content_func function wp_iframe($content_func /* ... */) { ?> >$filename | ||
$post->post_mime_type | ||
" . mysql2date($post->post_date, get_option('time_format')) . " | ||
" . apply_filters('media_meta', '', $post) . " | ||
$delete | $save$send | |
$save | ||
$delete | $send | "); } $hidden_fields = array(); foreach ( $form_fields as $id => $field ) { if ( $id{0} == '_' ) continue; if ( !empty($field['tr']) ) { $item .= $field['tr']; continue; } $field = array_merge($defaults, $field); $name = "attachments[$attachment_id][$id]"; if ( $field['input'] == 'hidden' ) { $hidden_fields[$name] = $field['value']; continue; } $required = $field['required'] ? '*' : ''; $item .= "\t\t|
\n\t\t\t | $required | \n\t\t\t"; if ( !empty($field[$field['input']]) ) $item .= $field[$field['input']]; elseif ( $field['input'] == 'textarea' ) { $item .= ""; } else { $item .= ""; } $item .= " | \n\t\t
$html | ||
{$form_fields['_final']} |