New uploads are broken
-
I have been running a network of WordPress sites (Multisite) since version 3.8.1. I’ve been constantly updating plugins and core. At some point, I discovered that uploading new images yields broken results.
When I upload a file it goes to
wp-content/blogs.dir/7/files
, 7 being the blog id. WordPress, for some reason thinks that it should link tohttps://siteurl.com/files/file-name.png
and therefore all images in Media Library or in newly added content are broken.I do not recall editing any configuration and previously all files went to the directory e.g.
wp-content/uploads/sites/7/files/2015/05/
. I was guessing that updating some plugin or core caused the behavior, but as I go in the history through a VCS, I cannot restore the previous upload behavior so it hints that the issue might be caused by file permissions, .htaccess or similar. I did try to play around with those as well, but to no success.When looking at the source code, I can’t figure out how it was working before. There’s a line that defines the upload path to be blogs.dir here https://github.com/WordPress/WordPress/blob/master/wp-includes/ms-default-constants.php#L31
I tried overriding these three values
define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); define( 'UPLOADS', UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" ); define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
with
define( 'UPLOADBLOGSDIR', WP_CONTENT_DIR . '/uploads' ); define( 'UPLOADS', UPLOADBLOGSDIR . "sites/{$wpdb->blogid}/" ); define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . "/uploads/{$wpdb->blogid}/" );
but I cannot get the $wpdb->blogid in the wp-config.php so it doesn’t work. And still, I can’t figure out how it was working before.
Any thoughts?
- The topic ‘New uploads are broken’ is closed to new replies.