__('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() { global $redir_tab; $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 image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) { if ( empty($alt) ) return $html; $id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; preg_match( '/width="([0-9]+)/', $html, $matches ); if ( ! isset($matches[1]) ) return $html; $width = $matches[1]; $html = preg_replace( '/align[^\s\'"]+\s?/', '', $html ); if ( empty($align) ) $align = 'none'; $shcode = '[wp_caption id="' . $id . '" align="align' . $align . '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/wp_caption]'; return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); } add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 ); 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; } function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { $overrides = array('test_form'=>false); $file = wp_handle_sideload($file_array, $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']; } $title = @$desc; // 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 $url; } 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) . " | |
$send $delete | |
\n\t\t\t | ";
if ( !empty($field[$field['input']]) )
$item .= $field[$field['input']];
elseif ( $field['input'] == 'textarea' ) {
$item .= "";
} else {
$item .= "";
}
if ( !empty($field['helps']) )
$item .= " " . join( " \n", array_unique((array) $field['helps']) ) . ' '; $item .= " | \n\t\t
---|---|
$html | |
{$form_fields['_final']} |
' . __('Also used as alternate text for the image') . '
' . __('Enter a link URL or click above for presets.') . '
* | |
---|---|
* | |
' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . ' | |
* | |
---|---|
* | |
' . __('Link text, e.g. "Lucy on YouTube"') . ' | |
* | |
---|---|
* | |
' . __('Link text, e.g. "Ransom Demands (PDF)"') . ' | |