2

All I did was adding this in my functions.php file:

function save_nb_image()
{
    global $wpdb;

            $id = $_POST['id'];
            $file = wp_get_attachment_url($id);

                if ( !is_wp_error($id) )
                {
                    $meta = wp_generate_attachment_metadata($id, $file);
                    $meta = nb_image_crop($meta);
                    wp_update_attachment_metadata($id, $meta);
                }

    wp_die();
}
add_action( 'wp_ajax_nb-image-autofix', 'save_nb_image' );

Then I tried to call it from a custom button in image edit form. Something didn't worked because nothing happened.

Then little later when I went into the Media Library again, the images wouldn't load. Chrome Console log said something about problem with mixed content. I have pretty recently changed to SSL/https so I thought that might been the problem. Although it's strange that change for some weeks ago make this affect now. I have been in media library a lot of times after that change and everything has worked perfectly.

But anyway, IF there is a SSL problem, I added "SSL Insecure Content Fixer" plugin to let that clear out everything. And I ran that plugin and then went in to the media library again. The console errors was now gone. But the images is still not loading. There is just a load spinner going on forever.

I have also tried activate the debug mode from wp_config but there is no related errors.

I have also tried re-installing the Wordpress version from Dashboard > Updates.

I have also of course tried remove the code I mentioned above.

What is there else to try?

Edit: I think it might be a database issue. Cause I even tried to remove all the files except /wp-content folder and wp-config.php file. And installed the older WP 4.4 version. Then went in and updated to latest version. After that: Still no images in grid view....

Edit, 27 feb 2017: I have found out that wp_get_attachment_url() was the wrong function to use since I wanted the absolute path and not the URL. So the right function to use is get_attached_file(). When I used the wp_get_attachment_url() function the ajax was loading very long time and returned a lot of strange code that I suspect was the image on some kind of code format. After changing to get_attached_file() the loading was much faster and the functionality of everything I wanted with the code did work as expected. However, maybe something with the earlier code made a mess in the database causing the Grid Mode problem?

0

I had a similar issue recently. I had moved over a theme with some plugin specific code in the functions.php. I forgot however to install said plugin. The grid view in the media gallery wouldn't load, but the list view would.

What Fixed It For Me

  • Remove plugin specific code from Functions file.
  • Install proper plugin
  • Add plugin specific code to Functions file.

I'm not sure if that will work for you but maybe check your plugins.

  • I tried to just remove ALL the code from functions.php. Didn't helped. And I can also mention that there is no response at all from ajax-post.php in Network -> ajax-post.php -> Response. – Peter Westerlund Feb 23 '17 at 7:43
  • Sorry I meant admin-ajax.php – Peter Westerlund Feb 23 '17 at 18:47
0

Problem is now solved. Thanks to user "blobfolio" here:

It sounds like you may have corrupted the image metadata. Have you tried running a plugin like https://wordpress.org/plugins/force-regenerate-thumbnails/ to regenerate the images/meta?

Solution:

So the solution is to force regenerate all the thumbnails. For example using the plugin mentioned above in the quote.

  • 1
    That does not fix it for me. – Sergi Mar 13 '18 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.