This topic describes how to store remote attachments from WordPress websites to OSS.

Prerequisites

  • OSS is activated and a bucket whose ACL is Public Read is created.
    • For more information about how to activate OSS, see Activate OSS.
    • For more information about how to create a bucket, see Create buckets.
  • A WordPress website is built.

Background information

The website remote attachment function allows you to directly store uploaded attachments to a remote storage server, which is usually a remote FTP server. Currently, Discuz! forums, PHPWind forums, and WordPress websites support the remote attachment function.

WordPress does not provide native support for this function, but you can use a third-party plug-in to implement this function. In this topic, the WordPress version is 4.3.1 and the plug-in is Hacklog Remote Attachment.

Procedure

  1. Log on to the WordPress website with an administrator account.
  2. Click Plugin. Enter FTP in the Keyword search bar. Press Enter.
  3. Find Hacklog Remote Attachment. Click Install Now.
  4. After the plug-in is installed, choose Settings > Hacklog Remote Attachment.
  5. In the Hacklog Remote Attachment dialog box that appears, configure the FTP service information.
    Configuration item Description
    FTP server Specifies the IP address that runs ossftp. We recommend that you set this parameter to 127.0.0.1.
    FTP server port number Specifies the port number of the FTP server. The default value is 2048.
    FTP account Specifies the FTP account in AccessKeyID/BucketName format. Note that the forward slash (/) is a delimiter and does not indicate an alternative.
    FTP password Specifies the FTP password AccessKey secret.
    FTP timeout Specifies the FTP timeout period. The default value is 30 seconds.
    Remote basic URL Specifies the public endpoint of the bucket. The format is http://BucketName.Endpoint. In this example, the bucket resides in the China (Hangzhou) region, and the bucket name is test-hz-jh-002. Therefore, the remote basic URL is http://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com/wp. For more information about endpoints, see OSS domain names.
    FTP remote path Specifies the path for storing the attachments in the bucket. 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 Specifies the HTTP remote path. We recommend that you set this parameter to a period (.).
  6. Click Save.
    Clicking Save triggers a test on the configuration. The test result is shown at the top of the page.
  7. Post a new article to verify whether the configuration is successful.
    1. After you have written a new article, click Add Media to upload an attachment.
    2. Click Post. You can see the article that you have just written.
    3. Right-click the image and choose Open Link in New Tab from the shortcut menu.
      The URL in the following figure indicates that the image has been uploaded to the OSS bucket test-hz-jh-002.