0

I noticed that my older images are no longer getting resolved by Wordpress 5.3.4. - the file doesn't exist on that path and 404 gets returned.

For images that were originally uploaded to

https://www.example.com/wp-content/uploads/myimage-300x300.jpg

Wordpress now looks here

https://www.example.com/wp-content/uploads/sites/1/myimage-300x300.jpg

The function I'm using to resolve image path (none works with old images):

https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/ <img class="full-size" src="<?php echo get_the_post_thumbnail_url($row['ID'], "medium"); ?>">

https://developer.wordpress.org/reference/functions/the_post_thumbnail/ <?php the_post_thumbnail( 'medium' ); ?>

I'm using Wordpress Multisite for several years already and never had this problem. Before, the older images of the used to be directly in wp-content/uploads/ directory.

The change could either be part of a Wordpress update or a side effect of the newly installed Elementor plugin.

How to overcome this change?

WP-Uploads

3
  • I think the default blog in the network uses the path without /sites/1/ etc. - have you changed the default blog in your network? Here's the code that adds /sites/, guarded by ! is_main_site().
    – Rup
    Jul 6, 2020 at 15:08
  • @Rup Not in the recent weeks and the problem started just recently, last thing I did was adding Elementor plugin. Here is my wp-config define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE', 2);. Both site 1 and 2 are having this issue (old images not resolved). Jul 6, 2020 at 15:14
  • @Rup you had the right answer. somehow the default blog got switched from site 1 to 2, so site 2 is now at the root of the directory. last time i changed that value was months ago, it’s strange that image loading worked until now. Jul 6, 2020 at 21:51

0

Your Answer

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