6

I have upgraded a neglected Wordpress installation the was a few versions off.

After the installation and upgrading multiple version, all of my images are now broken which were not before. Whenever I trace the filename back to the directory it should be in I see the same thing - the image is in existance, however Wordpress has appended a dimension x dimension to each of the references inside of Wordpress.

See what I mean:

Image file name being manipulated by Wordpress

Images broken in view

Directory listing, showing that the image is in existence

I have tried all solutions offered for similar WP issues however none have solved the problem.

After following this thread https://wordpress.org/support/topic/after-upgrade-to-44-media-files-are-not-showing I recieved a server 500 error.

Adding this conditional showed me the add_filter does not available inside functions.php

if (function_exists('add_filter')){
        add_filter('wp_get_attachment_image_attributes', function($attr) {
        if (isset($attr['sizes'])) unset($attr['sizes']);
        if (isset($attr['srcset'])) unset($attr['srcset']);
        return $attr;
    }, PHP_INT_MAX);

    add_filter('wp_calculate_image_sizes', '__return_false', PHP_INT_MAX);

    add_filter('wp_calculate_image_srcset', '__return_false', PHP_INT_MAX);

    remove_filter('the_content', 'wp_make_content_images_responsive');

} else echo 'No function exists for this method!';

Could someone please help me get Wordpress to stop referencing my images by the incorrect filename? Any help on this would be fantastic. Also when does Wordpress come up with these dimensions... are they specific to the viewport size or are these theme specific?

Please also note I have turned off all plugins and reverted to the default Wordpress theme as advised on the WP support site.

Thanks SO!

Update: Since none of the suggestions so far worked I will go back to an older version before responsive images feature is introduced and I will migrate again. I will let everyone know my progress. I am inclined to think that this is caused by removing the images during the installation (they were being scanned to make sure there was no virus/malware hidden in the images from the old infected box)

6
  • How precisely had you migrated the data? It's likely you have wrecked serialized image data in database at least that's the common issue and bulk of image data is stored serialized.
    – Rarst
    Commented Apr 1, 2016 at 15:39
  • all data is intact all images are intact however the refs arenbroken becuase wp is looking for srcset versions of the image. I was careful exporting and importing thwle data
    – AlphaG33k
    Commented Apr 1, 2016 at 15:47
  • Still how precisely did you migrate? Had domain changed? Did you perform any replacements on database?
    – Rarst
    Commented Apr 1, 2016 at 15:49
  • nope, normal installation yes domain is dependant on environment
    – AlphaG33k
    Commented Apr 1, 2016 at 15:50
  • 2
    Seems like you do not have the thumbnail size requested, maybe try regenerating them via the following plugin »Regenerate Thumbnails«. Commented Apr 4, 2016 at 12:44

1 Answer 1

4
+50

I think a quick thumbnail regeneration might be the cure for this. Try using Regenerate Thumbnails or a similar plugin, but backup your uploads directory before proceeding.

In order to just disable WP responsive images use this filter.

/**
 * Disable WP 4.4 srcset
 */
add_filter( 'wp_calculate_image_srcset', '__return_empty_array' );
5
  • Thanks @Zlatev, where should this filter be placed?
    – AlphaG33k
    Commented Apr 4, 2016 at 15:01
  • Theme's functions.php should be fine.
    – Z. Zlatev
    Commented Apr 4, 2016 at 15:02
  • After adding the filter to wp-includes/functions.php, server 500 error. Is there a different functons.php I should be adding this to?
    – AlphaG33k
    Commented Apr 4, 2016 at 15:06
  • Nevermind I found it but this still gives me the same broken image refs even though no server 500 error :( trying the plugin next.
    – AlphaG33k
    Commented Apr 4, 2016 at 15:18
  • The plugin worked :) thank you. Here is an easy 50 points for you!
    – AlphaG33k
    Commented Apr 4, 2016 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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