Opened 8 years ago
Closed 8 years ago
#39511 closed defect (bug) (fixed)
JS Error: Cannot read property 'models' of undefined in wp-includes/js/media-views.js at line no 7727
Reported by: | chandrapatel | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Media | Keywords: | commit |
Focuses: | javascript | Cc: |
Description
Below are the steps to reproduce this JS error.
- 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' ); } );
- Create New Post -> Click on
Add Media
-> Click onCustom Media Upload
and than close pop-up.
- 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.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
@chandrapatel Thanks for your detailed bug report and the patch. The check seems quite reasonable and appropriate here.
I was able to reproduce the issue you described and see the error in my console when attempting to upload, and I am unable to upload images.
After applying your patch I verified I no longer see the console message, and image uploading works fine.