mirror of
git://develop.git.wordpress.org/
synced 2025-02-27 10:02:43 +01:00
Make thumbnail work for custom post types even if the editor is not being displayed. props scribu. fixes #12792
git-svn-id: https://develop.svn.wordpress.org/trunk@14015 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
697e807eb0
commit
7c6b7b0a91
@ -351,18 +351,6 @@ if ( is_string($content_func) )
|
||||
* @since unknown
|
||||
*/
|
||||
function media_buttons() {
|
||||
global $post_ID, $temp_ID;
|
||||
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
|
||||
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
|
||||
$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
|
||||
$media_title = __('Add Media');
|
||||
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image");
|
||||
$image_title = __('Add an Image');
|
||||
$video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video");
|
||||
$video_title = __('Add Video');
|
||||
$audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio");
|
||||
$audio_title = __('Add Audio');
|
||||
|
||||
$do_image = $do_audio = $do_video = true;
|
||||
if ( is_multisite() ) {
|
||||
$media_buttons = get_site_option( 'mu_media_buttons' );
|
||||
@ -376,17 +364,36 @@ function media_buttons() {
|
||||
$out = '';
|
||||
|
||||
if ( $do_image )
|
||||
$out .= "<a href='{$image_upload_iframe_src}&TB_iframe=true' id='add_image' class='thickbox' title='$image_title' onclick='return false;'><img src='" . esc_url( admin_url( 'images/media-button-image.gif' ) ) . "' alt='$image_title' /></a>";
|
||||
$out .= _media_button(__('Add an Image'), 'images/media-button-image.gif', 'image');
|
||||
if ( $do_video )
|
||||
$out .= "<a href='{$video_upload_iframe_src}&TB_iframe=true' id='add_video' class='thickbox' title='$video_title' onclick='return false;'><img src='" . esc_url( admin_url( 'images/media-button-video.gif' ) ) . "' alt='$video_title' /></a>";
|
||||
$out .= _media_button(__('Add Video'), 'images/media-button-video.gif', 'video');
|
||||
if ( $do_audio )
|
||||
$out .= "<a href='{$audio_upload_iframe_src}&TB_iframe=true' id='add_audio' class='thickbox' title='$audio_title' onclick='return false;'><img src='" . esc_url( admin_url( 'images/media-button-music.gif' ) ) . "' alt='$audio_title' /></a>";
|
||||
$out .= "<a href='{$media_upload_iframe_src}&TB_iframe=true' id='add_media' class='thickbox' title='$media_title' onclick='return false;'><img src='" . esc_url( admin_url( 'images/media-button-other.gif' ) ) . "' alt='$media_title' /></a>";
|
||||
$out .= _media_button(__('Add Audio'), 'images/media-button-music.gif', 'audio');
|
||||
|
||||
$out .= _media_button(__('Add Media'), 'images/media-button-other.gif', 'media');
|
||||
|
||||
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
|
||||
|
||||
printf($context, $out);
|
||||
}
|
||||
add_action( 'media_buttons', 'media_buttons' );
|
||||
|
||||
function _media_button($title, $icon, $type) {
|
||||
return "<a href='" . get_upload_iframe_src($type) . "' id='add_$type' class='thickbox' title='$title'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' /></a>";
|
||||
}
|
||||
|
||||
function get_upload_iframe_src($type) {
|
||||
global $post_ID, $temp_ID;
|
||||
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
|
||||
$upload_iframe_src = add_query_arg('post_id', $uploading_iframe_ID, 'media-upload.php');
|
||||
|
||||
if ( 'media' != $type )
|
||||
$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
|
||||
$upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
|
||||
|
||||
return add_query_arg('TB_iframe', true, $upload_iframe_src);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@internal Missing Short Description}}
|
||||
*
|
||||
|
@ -1143,7 +1143,9 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
||||
*/
|
||||
function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
|
||||
global $content_width, $_wp_additional_image_sizes;
|
||||
$content = '<p class="hide-if-no-js"><a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . esc_html__( 'Set featured image' ) . '</a></p>';
|
||||
|
||||
$set_thumbnail_link = '<p class="hide-if-no-js"><a href="' . get_upload_iframe_src('image') . '" id="set-post-thumbnail" class="thickbox">%s</a></p>';
|
||||
$content = sprintf($set_thumbnail_link, esc_html__( 'Set featured image' ));
|
||||
|
||||
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
|
||||
$old_content_width = $content_width;
|
||||
@ -1153,7 +1155,7 @@ function _wp_post_thumbnail_html( $thumbnail_id = NULL ) {
|
||||
else
|
||||
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
|
||||
if ( !empty( $thumbnail_html ) ) {
|
||||
$content = '<a href="#" id="set-post-thumbnail" onclick="jQuery(\'#add_image\').click();return false;">' . $thumbnail_html . '</a>';
|
||||
$content = sprintf($set_thumbnail_link, $thumbnail_html);
|
||||
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail();return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
|
||||
}
|
||||
$content_width = $old_content_width;
|
||||
|
@ -23,7 +23,7 @@ jQuery(document).ready(function(){
|
||||
|
||||
//add thickbox to href & area elements that have a class of .thickbox
|
||||
function tb_init(domChunk){
|
||||
jQuery(domChunk).click(function(){
|
||||
jQuery(domChunk).live('click', function(){
|
||||
var t = this.title || this.name || null;
|
||||
var a = this.href || this.alt;
|
||||
var g = this.rel || false;
|
||||
|
@ -167,7 +167,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
$scripts->add( 'jquery-autocomplete', "/wp-includes/js/jquery/autocomplete$suffix.js", array('jquery'), '1.1' );
|
||||
$scripts->add_data( 'jquery-autocomplete', 'group', 1 );
|
||||
|
||||
$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20100108');
|
||||
$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20104104');
|
||||
$scripts->add_data( 'thickbox', 'group', 1 );
|
||||
$scripts->localize( 'thickbox', 'thickboxL10n', array(
|
||||
'next' => __('Next >'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user