WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#27753 closed defect (bug) (invalid)

wp_enqueue_media() breaks featured image functionality

Reported by: hovida Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.2
Component: Media Keywords:
Focuses: javascript Cc:

Description (last modified by SergeyBiryukov)

Hey there,

The bug #23028 still exists.

It was very annoying to find the problem. If you add the wp_enqueue_media functionality on themes or plugins, the media manager wont work correctly.

The bug exists on the actual stable (3.8.2) up to beta releases (tested in 3.9 RC1 and 3.9 RC3).

<?php
	class Media_Demo {
		public function __construct() {
			add_action('admin_init', array($this, 'admin_init'));
		}
		
		public function admin_init() {
			if(function_exists('wp_enqueue_media')){
				wp_enqueue_media();
			} else {
				wp_enqueue_style('thickbox');
				wp_enqueue_script('media-upload');
				wp_enqueue_script('thickbox');
			}
		}
	}
	
	new Media_Demo();
?>


Change History (4)

#1 @hovida
3 years ago

  • Summary changed from wp_enqueue_media() breaks fetured image functionality (reopen) to wp_enqueue_media() breaks featured image functionality (reopen)

#2 @SergeyBiryukov
3 years ago

  • Component changed from General to Media
  • Description modified (diff)
  • Focuses javascript added; accessibility removed
  • Summary changed from wp_enqueue_media() breaks featured image functionality (reopen) to wp_enqueue_media() breaks featured image functionality

#3 @ericlewis
3 years ago

  • Resolution set to invalid
  • Status changed from new to closed

wp_enqueue_media() consumes an arguments hash which includes an option for post, which you can pass anything that get_post(). This feeds into the JS of the media experience for Edit Post-specific functionality, so it can contextually know which post you are editing. Core does this, and so should you.

#4 @SergeyBiryukov
3 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.