voceconnect / multi-post-thumbnails

Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
143 stars 63 forks source link

Post ID not sent to media window #41

Closed Screenfeed closed 10 years ago

Screenfeed commented 10 years ago

Hi,

In your enqueue_admin_scripts()method you use wp_enqueue_media() but you omit to specify the post ID. It's a problem if a script or a plugin needs that ID in the media window. Solution:

public function enqueue_admin_scripts( $hook ) {
    global $wp_version, $post_ID;

    // ...
    } else { // 3.5+ media modal
        wp_enqueue_media( array( 'post' => ($post_ID ? $post_ID : null) ) );
        // ...
}

Thanks. Greg

chrisscott commented 10 years ago

Can't you use the post_id variable set in HEAD by the admin for this?

Screenfeed commented 10 years ago

Nope, $GLOBALS['post_id'] or $GLOBALS['post_ID'] are not set in admin-ajax.php.

chrisscott commented 10 years ago

Sorry, I had assumed you were talking about js access to it.

Screenfeed commented 10 years ago

In my case, I need the post type inside the filter 'image_size_names_choose', which is used in the media modal. The only way to have it is by using $_POST['post_id'], but $_POST['post_id'] is only sent if we specify it in the wp_enqueue_media()parameters.

chrisscott commented 10 years ago

I'll have a release out and publish to .org soon.

Screenfeed commented 10 years ago

Thanks :)