How to store remote attachments from WordPress to OSS

更新时间:
复制 MD 格式

This topic describes how to store attachments for a WordPress personal website in a remote location.

Prerequisites

  • You have activated OSS and created a bucket with the public-read permission.
  • You have set up a personal WordPress website.

Background information

The remote attachment feature stores uploaded attachments directly on a remote storage server. This is typically done over FTP. Platforms such as Discuz! forums, PHPWind forums, and WordPress websites support this feature.

WordPress does not natively support this feature. However, you can use a third-party plugin to implement it. This topic uses WordPress 4.3.1 and the Hacklog Remote Attachment plugin as an example.

Procedure

  1. Log in to your WordPress site with an administrator account.
  2. Click Plugin, and enter FTP in the Keyword
  3. Find Hacklog Remote Attachment and click Install Now.
  4. After the plugin is installed, click Settings > Hacklog Remote Attachment.
  5. In the Hacklog Remote Attachment Options dialog box, configure the FTP service information.
    Configuration item Description
    FTP server The address where the OSS FTP tool runs. Typically, this is 127.0.0.1.
    FTP server port The default value is 2048.
    FTP username The format is AccessKeyID/BucketName. The forward slash (/) is a delimiter, not an 'or' operator.
    FTP password AccessKey secret.
    FTP timeout The default value is 30 seconds.
    Remote base URL The public endpoint of the bucket. The format is http://BucketName.Endpoint. In this example, the bucket is named test-hz-jh-002 and 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 storage path for attachments in the bucket. In this example, `wp` indicates that all attachments are stored in the `wp` folder of the bucket. The Remote base URL must correspond to the FTP remote path.
    HTTP remote path Enter a period (.).
  6. Click Save.
    When you click Save, a configuration test runs. The result appears at the top of the page.
  7. Publish a new article to verify the configuration.
    1. When writing a new article, click Add Media to upload an attachment.
      The following figure shows an attachment being uploaded.
    2. Click Publish to view the new article.
    3. Right-click the image and select Open link in new tab.
      The URL in the figure shows that the image has been uploaded to the `test-hz-jh-002` bucket in OSS.