This topic describes how to offload media attachments from your WordPress website to OSS.
Prerequisites
-
You have activated OSS and created a bucket with public-read permissions.
-
To learn how to activate OSS, see Activate OSS.
-
To learn how to create a bucket, see Create a bucket.
-
-
You have a self-hosted WordPress website.
Background
The remote attachment feature lets you store files uploaded to your website directly on a remote storage server, typically by using File Transfer Protocol (FTP). Platforms such as Discuz!, phpwind, and WordPress support this feature.
WordPress does not natively support remote attachments. However, you can use a third-party plug-in to enable this feature. This tutorial uses WordPress 4.3.1 and the Hacklog Remote Attachment plug-in as an example.
Procedure
-
Log in to your WordPress dashboard with an administrator account.
-
Click Plugins, enter FTP in the Keyword search box, and then press Enter.
-
Find Hacklog Remote Attachment and click Install Now.
-
After the plug-in is installed, go to .
-
In the Hacklog Remote Attachment Options dialog box, configure the FTP server settings.
Parameter
Description
FTP server
The IP address of the server that runs the ossftp tool. In most cases, you can enter 127.0.0.1.
FTP server port
The default value is 2048.
FTP account
The format is AccessKeyID/BucketName, where the forward slash (/) acts as a separator.
FTP password
Your AccessKeySecret.
FTP timeout
The timeout period for the FTP connection. You can use the default value of 30 seconds.
remote basic URL
The public endpoint of your bucket. The format is http://BucketName.Endpoint. In this example, the bucket named test-hz-jh-002 is in the China (Hangzhou) region. Therefore, the URL is http://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com/wp. For more information about endpoints, see Access OSS over IPv6.
FTP remote path
The directory in your bucket where attachments are stored. In this example, wp indicates that all attachments are stored in the wp directory of the bucket. The remote basic URL must correspond to the FTP remote path.
HTTP remote path
Enter a period (.).
-
Click Save.
When you click Save, the plug-in automatically tests your configuration. The test result is displayed at the top of the page.
-
Create a new post to verify the configuration.
-
While writing a new post, click Add Media to upload an attachment.
-
Click Publish. The new post is displayed.
-
Right-click the image and select Open Link in New Tab.
The URL in the new tab confirms that the image is in the test-hz-jh-002 bucket in OSS.
-