From 12c21bf931b629e38f39a65af990bfda3f48bce2 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Thu, 6 Sep 2012 08:49:35 +0000 Subject: [PATCH] First pass at integrating featured images with the new media workflow. Updates the featured image when the publish/update button is clicked (rather than instantly). Uses the existing post_thumbnail_meta_box() function. Does not remove the old featured image meta box JS, ajax handler, or CSS. see #21776, #21390. git-svn-id: http://core.svn.wordpress.org/trunk@21770 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/css/wp-admin.css | 29 ++++++++++++ wp-admin/includes/meta-boxes.php | 75 ++++++++++++++++++++++++++++++-- wp-admin/includes/post.php | 8 ++++ wp-includes/script-loader.php | 1 - 4 files changed, 109 insertions(+), 4 deletions(-) diff --git a/wp-admin/css/wp-admin.css b/wp-admin/css/wp-admin.css index a10f1ceca7..89f4797840 100644 --- a/wp-admin/css/wp-admin.css +++ b/wp-admin/css/wp-admin.css @@ -23,6 +23,7 @@ TABLE OF CONTENTS: 11.0 - Write/Edit Post Screen 11.1 - Custom Fields 11.2 - Post Revisions + 11.3 - Featured Images 12.0 - Categories 13.0 - Tags 14.0 - Media Screen @@ -3239,6 +3240,34 @@ table.diff .diff-deletedline del, table.diff .diff-addedline ins { text-decoration: none; } +/*------------------------------------------------------------------------------ + 11.3 - Featured Images +------------------------------------------------------------------------------*/ + +#select-featured-image { + padding: 4px 0; + overflow: hidden; +} + +#select-featured-image img { + max-width: 100%; + height: auto; + margin-bottom: 10px; +} + +#select-featured-image a { + float: left; + clear: both; +} + +#select-featured-image .remove { + display: none; + margin-top: 10px; +} + +#select-featured-image.has-featured-image .remove { + display: inline-block; +} /*------------------------------------------------------------------------------ 12.0 - Categories diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index c4a095e24d..09bfeb535c 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -911,6 +911,75 @@ function link_advanced_meta_box($link) { * @since 2.9.0 */ function post_thumbnail_meta_box( $post ) { - $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); - echo _wp_post_thumbnail_html( $thumbnail_id ); -} + global $_wp_additional_image_sizes; + + ?> + + ID, '_thumbnail_id', true ); + $thumbnail_size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : 'medium'; + $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $thumbnail_size ); + + $classes = empty( $thumbnail_id ) ? '' : 'has-featured-image'; + + ?> + $value ) { diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 5a0962e674..5fdc7e5335 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -318,7 +318,6 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'media-models', 'wp-plupload' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'media-views', '_wpMediaViewsL10n', array( 'insertMedia' => __( 'Insert Media' ), - 'chooseFeatured' => __( 'Choose a Featured Image' ), 'selectMediaSingular' => __( 'Select a media file:' ), 'selectMediaMultiple' => __( 'Select one or more media files:' ), ) );