0
votes

An automatic upgrade to Wordpress 3.9 broke the "Add media" functionality for posts on our client's site...when you click "Add media", it wasn't showing any of the photos in the media library (just had a blank area where the photos should be), even though those photos are still there when you go to the Media Library via the "Media" menu item in the main navigation.

Since then, I have tried upgrading to Wordpress 3.9.2, disabling all plugins, and setting the theme to the default TwentyTen theme. The issue still remains, and the only difference after all of that is that the upgrade to Wordpress 3.9.2 (from an earlier 3.9 version) seems to have caused a spinning icon to appear in the area where the photos should load, but it just spins forever and the photos never load.

I looked at the AJAX calls in Chrome Developer Tools and found that the admin_ajax.php call is actually returning the correct data, including all the correct image paths, so that's not the problem...I'm thinking there must be some Javascript-related issue that's causing the images not to appear.

Debugging this further, I found the initialize() function of media.controller.GalleryAdd, which is a standard Wordpress file at wp-includes/js/media-views.js. I added the console.log() function to see what was going on:

    initialize: function() {
        // If we haven't been provided a `library`, create a `Selection`.
        if ( ! this.get('library') ) {
            console.log('media.query result', media.query({ type: 'image' }) )

            this.set( 'library', media.query({ type: 'image' }) );
        }

        media.controller.Library.prototype.initialize.apply( this, arguments );
    }

Wordpress uses Backbone.js, and although I don't know Backbone, I found what looks like a problem here...the media.query() result has a length of 0 and its models array is empty.

I am trying to debug further to find the source of the problem, but I'm not all that familiar with the Wordpress source code and as I mentioned I'm not familiar with Backbone either, and it would be nice to get this resolved without having to spend hours upon hours debugging it more.

Can anyone provide any ideas/suggestions as to what might be the problem here?

2
First - You can try upgrade to wp 4.0. second - try also another browser / machine . A fresh install without plugins / themes / mu-plugins will not have that issue . if you have it on a clean install with no plugins and no theme modifications- then reinstall.Obmerk Kronen
Thanks, I'll give the upgrade to 4.0 a try on the dev site (it hadn't come out yet when I did the initial upgrade)...Reinstalling would be a last resort as this is an existing site with a number of customizations in place already.Matt Browne
So these customizations are the problem.. You said in original question that you reset all plugins / themes/ mu ...Obmerk Kronen
Yes I did, and they are still disabled on the dev site, but I would like to re-enable them once I resolve the issue. I tried to disable all customizations, but since I've already disabled all plugins (even renamed the plugins folder) and changed the theme, I'm not sure what else I can do on that front. I suppose if I can't find the cause of the issue I could start with a fresh installation and move things over one by one.Matt Browne
I figured out what was causing the problem (see my answer below). Thanks for the pointers though - it was when I was starting to upgrade to Wordpress 4.0 that I noticed some errors about output having already started from wp-config.php.Matt Browne

2 Answers

0
votes

I figured out what the problem was, and it was surprisingly simple...it was caused by extra whitespace at the end of wp-config.php! I simply removed the closing ?> tag at the bottom of the file to avoid whitespace from causing any problems in the future (I personally always omit the closing ?> tag in my own code but this site was built by someone else.) I'm guessing that the whitespace was interfering with header() function somewhere in the Wordpress code, causing the media gallery window to stop working.

0
votes

I had the same issue, I fund that two jQuery files were missing jquery.ui.tabs.min.js and jquery.ui.tooltip.min.js. I found the source in Google Code. they need to be placed in wp-includes/js/jquery/ui