[wp-trac] [WordPress Trac] #39511: JS Error: Cannot read property 'models' of undefined in wp-includes/js/media-views.js at line no 7727

WordPress Trac noreply at wordpress.org
Fri Jan 6 20:51:30 UTC 2017


#39511: JS Error: Cannot read property 'models' of undefined in wp-includes/js
/media-views.js at line no 7727
--------------------------+-----------------------------
 Reporter:  chandrapatel  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  4.6
 Severity:  normal        |   Keywords:
  Focuses:  javascript    |
--------------------------+-----------------------------
 Below are the steps to reproduce this JS error.

 1. Add this code in plugin or in mu-plugins directory.

 {{{
 <?php

 function cmu_media_menu( $tabs ) {
     $newtab = array( 'cmu' => 'Custom Media Upload' );
     return array_merge( $tabs, $newtab );
 }

 add_filter( 'media_upload_tabs', 'cmu_media_menu' );

 function cmu_media_handle() {
     echo 'Hey Everyone !';
 }

 add_action( 'media_upload_cmu', function() {
     return wp_iframe( 'cmu_media_handle' );
 } );
 }}}

 2. Create New Post -> Click on `Add Media` -> Click on `Custom Media
 Upload` and than close pop-up.

 3. Now click on Featured Image than click on Upload Files tab and than try
 to upload file. You will get JS error as mentioned above.

 `selection` and `library` state are not set for custom tabs.

 Simple solution is like add `if` condition. I've added initial patch.

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


More information about the wp-trac mailing list