Store media attachments uploaded to your WordPress site directly in an OSS bucket. This offloads media storage from your web server and serves uploaded files through the bucket's public endpoint.
This guide covers:
Installing the Hacklog Remote Attachment plug-in
Configuring FTP settings to point to your OSS bucket
Verifying that new uploads are stored in OSS
Prerequisites
Before you begin, ensure that you have:
An OSS bucket with a public read access control list (ACL). See Activate OSS and Create buckets
A running WordPress installation
An AccessKey ID and AccessKey secret for your Alibaba Cloud account
How it works
WordPress does not natively support remote attachment storage. The Hacklog Remote Attachment plug-in bridges this gap by connecting WordPress to an OSS FTP service (ossftp) running on your server. When you upload media in WordPress, the plug-in sends the file to ossftp, which stores it in your bucket.
This guide uses WordPress 4.3.1 and the Hacklog Remote Attachment plug-in.
The remote attachment feature is also supported on Discuz! and PHPWind forums.
Install and configure the plug-in
Install the plug-in
Log in to your WordPress admin dashboard using an administrator account.
Click Plug-in in the sidebar.
In the Keyword search bar, type
FTPand press Enter.Find Hacklog Remote Attachment
After installation, choose Settings > Hacklog Remote Attachment.
Configure FTP settings
In the Hacklog Remote Attachment Options dialog box, fill in the following fields:
| Parameter | Description | Example |
|---|---|---|
| FTP server | IP address of the server running ossftp. Set this to 127.0.0.1 if ossftp runs on the same server as WordPress. | 127.0.0.1 |
| FTP server port number | Port that ossftp listens on. The default is 2048. | 2048 |
| FTP account | Your credentials in AccessKeyID/BucketName format. The forward slash (/) is a delimiter, not an alternative symbol. | LTAI5tXxx/my-bucket |
| FTP password | Your AccessKey secret. | — |
| FTP timeout | Connection timeout in seconds. The default is 30. | 30 |
| Remote basic URL | Public URL prefix for files stored in the bucket. The format is http://BucketName.Endpoint. To find your endpoint, see OSS domain names. | http://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com/wp |
| FTP remote path | Directory inside the bucket where attachments are stored. This value must match the path suffix in Remote basic URL. | wp |
| HTTP remote path | Set this to a period (.). | . |
Constructing the remote basic URL
The URL combines your bucket name, the regional endpoint, and the FTP remote path:
http://<BucketName>.<Endpoint>/<FTPRemotePath>To identify the parts from your bucket's details:
BucketName: the name of your OSS bucket (for example,
test-hz-jh-002)Endpoint: the endpoint for your bucket's region (for example,
oss-cn-hangzhou.aliyuncs.comfor China (Hangzhou))FTPRemotePath: the directory name you choose for storing attachments (for example,
wp)
The resulting URL for a bucket named test-hz-jh-002 in the China (Hangzhou) region with a remote path of wp is:
http://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com/wpReplace oss-cn-hangzhou.aliyuncs.com with the endpoint for your region. For a full list of endpoints, see OSS domain names.
Save and test
Click Save
Verify the configuration
Create a new post in WordPress.
Click Add Media
Click Post
Right-click the image in the published post and choose Open Link in New Tab.
If the configuration is correct, the image URL uses your bucket's public endpoint, confirming that WordPress is storing new media attachments in OSS.
What's next
To serve media through your own domain name, bind a custom domain to your bucket. See Bind custom domain names.
To improve global access performance, configure Alibaba Cloud CDN to distribute your media from OSS edge nodes.