Make thumbnail work for custom post types even if the editor is not being displayed. props scribu. fixes #12792

git-svn-id: http://svn.automattic.com/wordpress/trunk@14015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith
2010-04-06 11:20:47 +00:00
parent f1fd3f2780
commit 07a523894a
4 changed files with 29 additions and 20 deletions

View File

@@ -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;