Make WordPress Core


Ignore:
Timestamp:
12/03/2012 02:38:10 AM (13 years ago)
Author:
nacin
Message:

Bring Featured Images back into the main media dialog.

Most users don't realize that the Featured Image meta box exists; if they do, few use it.

Restores the old meta box UI, including the admin_post_thumbnail_html filter. If a plugin is using _wp_post_thumbnail_html() in conjunction with Thickbox elsewhere, it will also magically still work.

Specific underlying changes:

  • Converts the modal view to use the view manager, which means that a call to open() will automatically call render and attach if necessary.
  • Doesn't automatically set a state in wp.media, to allow code to customize the states to be added before activation.

props koopersmith.
fixes #21776.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/media.php

    r22978 r22979  
    14351435        $settings['postId'] = $post->ID;
    14361436        $settings['nonce']['updatePost'] = wp_create_nonce( 'update-post_' . $post->ID );
     1437
     1438        if ( current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' ) ) {
     1439
     1440            $featuredImageId = get_post_meta( $post->ID, '_thumbnail_id', true );
     1441
     1442            $settings['featuredImage'] = array(
     1443                'id'    => $featuredImageId ? $featuredImageId : -1,
     1444                'nonce' => wp_create_nonce( 'set_post_thumbnail-' . $post->ID ),
     1445            );
     1446        }
    14371447    }
    14381448
     
    14681478        'fromUrlTitle'       => __( 'From URL' ),
    14691479
     1480        // Featured Images
     1481        'featuredImageTitle'  => __( 'Featured Image' ),
     1482        'setFeaturedImage'    => __( 'Set featured image' ),
     1483
    14701484        // Gallery
    14711485        'createGalleryTitle' => __( 'Create Gallery' ),
     
    15121526            <h3 class="media-modal-title">{{ data.title }}</h3>
    15131527            <a class="media-modal-close media-modal-icon" href="#" title="<?php esc_attr_e('Close'); ?>"></a>
     1528            <div class="media-modal-content"></div>
    15141529        </div>
    15151530        <div class="media-modal-backdrop">
Note: See TracChangeset for help on using the changeset viewer.