Root's "Change default upload location from wp-content/uploads" not working

Hi everyone,

Root’s action to change the default media upload location from wp-content/uploads to media does not work.

When uploading media, it uploads to the /media folder as it should but it does not link to it correctly. The images appear with just the border, blank white space and a broken image symbol image in the middle. The thumbnails are also broken like this.

Any ideas?

Thank you

**

UPDATE: Thanks to @lautreamont this problem was SOLVED! The solution was changing the directory permissions on my “media” folder to 755. Thank you lautreamont!

**

This will help for single and multisite to give you a better understanding - http://codex.wordpress.org/Function_Reference/wp_upload_dir

Thank you for the response but I have already been to this page and I’m not sure how it can help me fix the problem.

The files are getting uploaded to the right location but there seems to be a problem with roots pointing to that right location. I’m not sure where roots is doing this, why it’s doing it or how to fix it.

mysite.com/public_html/media/Capture322-150x123.jpg
leads to a wordpress “Not Found” page even though that’s the path to the file.

I am also having the same issue in the latest branch of Roots now.

I am currently having a look at /lib/activation.php at around line 189 to see if I can find a solution. I remember now that I had the same issue before with the previous branch and managed to solve it but I can’t remember how.

Let me know if you find anything.

Quite honestly, upon activation of the theme next time I wont opt to let the activation change the media upload location again since it just ends up wasting my time to solve the issue afterwards, twice now.

There is an option upon activation, I don’t know if you have noticed as you activated the theme?

I am however working on a local install with XAMPP and haven’t tried it on a live server yet. Are you also working local?

@anon73570552 Can you provide a little background about your server setup? Is it shared hosting?

@Foxaii Dedicated server Centos 5.9 x64
PHP 5.3.21 / FastCGI
MySQL 5.1.70
Latest version of Roots on WP 3.6

@howdous - not working locally. Yes, saw the option upon theme activation. Assuming it’s a problem with roots, should probably fix it or remove the option.

I dont think that is roots theme error or wrong doing. Changig upload directorium relativly to wp-content is Wordpress option. Roots just use that option, in my opinion Roots use this idea half-way because it is more usefull to move hole wp-content. That way you may have two directory project with Wordpress stuff in one and user stuff in the other.
I am not an expert but I check how many .htaccess files I have in project tree and are they different. I mean:

[site_dir]/.htaccess

[site_dir]/wp/.htaccess

I sad I am not shure but if thay differ in RewriteBase in my opinion relative addresses wont work.

In most cases public_html would be the web root, and as such should not actually feature in the url.

My best guess would be there’s a setting on your server, or the WordPress setup itself, that the WordPress code (Roots changes the setting with a WordPress function) does not like.

When you go to change the path, does it show the public_html in the path? If so try deleting it.

@Foxaii thank you for the response. If I change the path to media it creates a media folder inside of the public_html directory. If I change the path to public_html/media it creates a path that looks like public_html/public_html/media

The problem does not appear to be the actual location and uploading of media – that works just fine as it should. The problem appears to be how WordPress is pulling the image after it’s been uploaded.

Example: mysite.com/media/anyimage.jpg will lead to a WordPress theme “Not Found” page even though there is a /media/anyimage.jpg file on the server.

Where is instalation of WP.
Is it in subdirectory or root directroy.
If in sub did you named it “public_html”?

If you say that every thing is ok with upload do you see images when you in the Media Library?

WP is installed in the root of the website (no subdirectory).

The thumbnail icons in the Media Library are broken, but if I go click “edit” then “edit image” – the image will pop up to edit.

Check in Settings->Media if:

“Store uploads in this folder” is “media”

and

“Full URL path to files” must be empty.

Already tried that. I tried leaving Full URL path to files empty as well as trying to add the path to the media folder – neither of which worked.

Also, in .htaccess it has this:
RewriteRule ^assets/(.) /wp-content/themes/mytheme/assets/$1 [QSA,L]
RewriteRule ^plugins/(.
) /wp-content/plugins/$1 [QSA,L]

I tried adding RewriteRule ^media/(.*) /wp-content/uploads/$1 [QSA,L] but it did not work. The images just still appear as being from wp-content/uploads (so it did nothing).

I’m wondering if there’s somewhere in Roots I need to also define this.

Yeah I’m pretty sure the rewrites are done in lib/rewrites.php but I don’t know PHP very well…

If anyone has any knowledge of it, that would be awesome…

You are wrong about rewrites, because, like you see for yourself it only address access to assets and plugins. Changing upload directory is WP option. You can do it without ROOTS on any WP theme from wp-config.php.

Only way that I get on my instalation problem like yours is that I define diferent “relative media directory” and “absolute media directory”. Check your wp-config or plugins that you use.

I understand the re-write does not change the location and that modifying the upload directory within WP itself is possible.

It is not a plugin issue as I have disabled every plugin when testing this. I have tried changing the upload destion in wp-config – it does not work. The images upload fine, to the location, but are not referenced in wordpress posts the way they should:

Example: mysite.com/media/anyimage.jpg will lead to a WordPress theme
"Not Found" page even though there is a /media/anyimage.jpg file on
the server.

This is what “Roots” does after activation

This is what happens after I upload a photo (1)
-

And the attachment page:

And when you go to mysite.com/media/file.jpg: