• 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 to https://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?

Viewing 1 replies (of 1 total)
  • Thread Starter Lightheaded

    (@lightheaded)

    P.S Just found out that uploads are working for the top level blog.
    I also tried uploading a file in the top level blog. It shows the link to /wp-content/uploads/2015/05/Screen-Shot-2015-05-29-at-09.56.02.png in media browser. Now when I open /wp-includes/ms-files.php?file=2015/05/Screen-Shot-2015-05-29-at-09.56.02.png I get a 404 and when I echo out the file path ms-files.php is trying to include, I get /wp-content/blogs.dir/1/files/2015/05/Screen-Shot-2015-05-29-at-09.56.02.png

Viewing 1 replies (of 1 total)
  • The topic ‘New uploads are broken’ is closed to new replies.