[wp-trac] [WordPress Trac] #42751: Can we please enqueue media-views independently ?

WordPress Trac noreply at wordpress.org
Wed Nov 29 22:14:12 UTC 2017


#42751: Can we please  enqueue media-views independently ?
-----------------------------------------+-----------------------------
 Reporter:  Themezly                     |      Owner:
     Type:  defect (bug)                 |     Status:  new
 Priority:  normal                       |  Milestone:  Awaiting Review
Component:  Media                        |    Version:  4.9
 Severity:  normal                       |   Keywords:
  Focuses:  administration, performance  |
-----------------------------------------+-----------------------------
 Many of theme developers are styling mediaelement to their preference and
 this is a first step when they do so;


 {{{
 /*
  * use theme mediaelement CSS
  */
 wp_deregister_style('mediaelement');
 wp_deregister_style('wp-mediaelement');
 }}}


 that disables the default CSS and lets us use our own. Issue with this is
 that
 buttons, imgareaselect and media-views CSS files depend on these and if
 anyone is using a frontend page builder or anything that needs media
 library in frontend, these 3 CSS files are not present.

 My first tought was


 {{{
 /*
  * since we have deregistered medialement style
  * make sure media dependencies are loaded
  * in case of frontend editros
  */
 if( is_user_logged_in() ){

         wp_enqueue_style( 'buttons' );
         wp_enqueue_style( 'imgareaselect' );
         wp_enqueue_style( 'media-views' ) ;

 }
 }}}


 but to my surprise media-views which is a key CSS file for media library
 is not loading since it is a dependent.

 I know that I can do the direct enque but since we have a handle we should
 be able to use it independently from other styles.

 While we are at it, why are we loading mediaelement CSS files at the
 bottom of body

 http://prntscr.com/hh0808  ?

 CSS files should always be in head.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42751>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list