__('Choose File'), // handler action suffix => tab text 'gallery' => __('Gallery'), 'library' => __('Media Library'), ); return apply_filters('media_upload_tabs', $_default_tabs); } function update_gallery_tab($tabs) { global $wpdb; if ( !isset($_REQUEST['post_id']) ) { unset($tabs['gallery']); return $tabs; } if ( intval($_REQUEST['post_id']) ) $attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id']))); $tabs['gallery'] = sprintf(__('Gallery (%s)'), "$attachments"); return $tabs; } add_filter('media_upload_tabs', 'update_gallery_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, $size); $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; if ( $url ) $html = '$html"; $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size ); 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 /* ... */) { ?> >* | |
---|---|
* | |
' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . ' | |
* | |
---|---|
* | |
' . __('Link text, e.g. "Lucy on YouTube"') . ' | |
* | |
---|---|
* | |
' . __('Link text, e.g. "Ransom Demands (PDF)"') . ' | |