vstamilan on "Defining custom uploads directory is broken in WP 4.5 (wp-config)"

ساخت وبلاگ

timsilva_
Member
Posted 3 weeks ago #

Hi all, after upgrading to WP 4.5, the following method for customizing the location of the default "/wp-content/uploads/" folder no longer seems to work: http://www.wpbeginner.com/wp-tutorials/how-to-change-the-default-media-upload-location-in-wordpress-3-5/ (or here: https://codex.wordpress.org/Editing_wp-config.php#Moving_uploads_folder) - (I was changing it to "/files/" instead, not that it matters :P )

I tried resetting it manually but wp-config.php doesn't seem to recognize:
define('UPLOADS','files');
...or...
define('UPLOADS',''.'files');
...when placed directly after...
require_once(ABSPATH . 'wp-settings.php');
...anymore. Anyone have any clue why?

This is leading for my code to request:
example.com/wp-content/uploads/2016/04/image.jpg
...when the actual location is:
example.com/files/2016/04/image.jpg

Many thanks! :)

timsilva_
Member
Posted 3 weeks ago #

Has no one else experienced issues with defining a custom uploads directory?

Plugin "WordPress Popular Posts" use?

timsilva_
Member
Posted 3 weeks ago #

Hey Sergey, glad to hear I'm not alone on this. I've been searching around all over with no luck.

In the worst-case scenario we could revert back to the default location for all hard-coded images, but that's obviously lots of manual work, and even the automated steps (find all and replace all) might not always be the safest...

I am juggling lots of work today, but if I stumble across any solution I will let you know. In the meantime, hopefully some others with the same issue come forward so we can have more minds on it.

I deactivated plugin WordPress Popular Posts and everything was good.
(Sorry for my English)

The same problem here =(

timsilva_
Member
Posted 3 weeks ago #

I don't have the "WordPress Popular Posts" plugin installed, but I haven't tried to disable plugins yet. I'm currently in the middle of some database work, so I'll try that when I get a chance and see if one of my plugins is causing the issue.

@skanslie - Do you have the "WordPress Popular Posts" plugin installed too?

Nope i dont

The problem in some plug-in

...when placed directly after...
require_once(ABSPATH . 'wp-settings.php');

Because that is the wrong place to put it in the wp-config.php file.

All "defines" should be at the top of the file. Including the "wp-settings.php" file is the last line of wp-config.php. It's the line that loads WordPress. Any defines made after this line will have no effect, because you're defining them after you have already loaded and ran the WordPress process.

Put your defines first, like the wp-config-sample.php file demonstrates.

timsilva_
Member
Posted 3 weeks ago #

@otto42 - Thanks for the suggestion Samuel! I'll give that a try ASAP. :)

I found the original tutorial that I leaed about this from: http://www.hongkiat.com/blog/wordpress-custom-upload-dir/ As you can see, they instructed to place the "Define" line after the require_once. For some strange reason, this was working for me (and others apparently) before. As soon as I confirm that your solution works, I will report back.

In the meantime, if anyone else has success (or not) with Samuel's idea, let us know!

Yeah, no define after that line will ever work. The tutorial is just wrong.

The other methods it mentions about setting the value in the options table will indeed work though. But you don't need both methods.

timsilva_
Member
Posted 3 weeks ago #

@otto42 - I owe you a beer my friend, thank you SO MUCH for noticing that tiny detail. You were 100% correct about my error. I moved the define uploads code up after the other defines, and it fixed the problem immediately!

Somehow, the old method was working for a long time. Unless I somehow moved the code at some point, but from what I can tell it has been that way for at least 6 months.

Hopefully that fixes the problem for other users.

Cheers,
Tim

If you're on Multisite, check the Upload Path and Fileupload Url settings in Network -> Sites -> Edit -> Settings

source: https://wordpress.org/support/topic/subdomain-multisite-correct-settings-for-upload-url-path?replies=8#post-4670992

vstamilan
Member
Posted 12 minutes ago #

timsilva_ Is this problem was resolved? Can you please guide me to resolve the same problem?

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 96 تاريخ : دوشنبه 20 ارديبهشت 1395 ساعت: 18:57