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?

3 Answers
3

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.

Leave a Reply

Your email address will not be published. Required fields are marked *