如何更改WordPress媒体上传目录

One thing I've always missed about the "old" way of web development was the simplicity of FTP. No deploy scripts, no fuss: simple drag and drop of files and the files are there. I've used FTP for assets on this blog for over a decade but I'm finally ready to be lazy enough to want to drag images into WordPress and use them as WordPress intended.

关于Web开发的“旧”方式,我一直想念的一件事是FTP的简单性。 无需部署脚本,无需大惊小怪:只需简单地拖放文件,文件就在那里。 我在这个博客上使用FTP作为资产已有十多年了,但是我终于准备好懒惰,想要将图像拖入WordPress并按WordPress的意图使用它们。

The problem is that I want the files to upload to custom directory, not the wp-content/uploads directory that WordPress defaults to. The following PHP snippet in the WordPress wp-config.php file allows you to change WordPress' default upload directory:

问题是我希望文件上传到自定义目录,而不是WordPress默认的wp-content/uploads目录。 WordPress wp-config.php文件中的以下PHP代码段可让您更改WordPress的默认上传目录:


require_once(ABSPATH.'wp-settings.php');
define('UPLOADS', 'my-demo');

Files uploaded within the WordPress / browser interface will be added in this custom directory. Note that WordPress will create the directory if not present, and will also automatically create and upload the file to a {year}/{month} directory within that custom directory.

在WordPress /浏览器界面中上传的文件将添加到此自定义目录中。 请注意,WordPress将创建目录(如果不存在),还将自动创建文件并将其上传到该自定义目录中的{year}/{month}目录。

I wish I had set this configuration years ago. Having to open a separate app and then write the custom HTML to insert this image has been an inconvenience for a long time!

我希望我在几年前设置了此配置。 很长时间以来,必须打开一个单独的应用程序,然后编写自定义HTML才能插入此图像,这给您带来了很大的不便!

翻译自: https://davidwalsh.name/wordpress-upload

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值