From 57ef61d5ab9c78fbedd12bb877055613334b39b8 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Thu, 16 Apr 2020 09:22:50 +0800 Subject: [PATCH] update version to 1.1.1 --- README.md | 7 +++++++ aliyun-oss-wordpress.php | 10 +++++----- readme.txt | 14 +++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f715a2b..f24a510 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,13 @@ Github 下载节点:[https://github.com/sy-records/aliyun-oss-wordpress/releas 因为Bucket是2019年9月23日后创建的,使用默认域名时会自动下载,需要绑定自有域名访问。具体参考[阿里云文档](https://help.aliyun.com/document_detail/142631.html)。 +* 如果存在第三方插件或者主题自带上传功能,内容上传到`本地文件夹`(即默认`wp-content/uploads`)中,怎么上传到oss中? + +解决方案有两种,推荐使用第二种。 + +一是修改第三方插件或者主题的上传功能,调用插件的`oss_file_upload`方法(不推荐,一般人不会修改) +二是使用对象存储OSS提供的回源功能,配置为镜像方式。如果配置了镜像回源,当用户对该存储空间内一个不存在的文件进行GET操作时,OSS会向回源地址请求这个文件,返回给用户,同时会将该文件存入OSS。这样就达到了上传到OSS的需求。具体配置参考阿里云文档[设置回源规则](https://help.aliyun.com/document_detail/31906.html) + ## 插件截图 ![设置页面](screenshot-1.png) diff --git a/aliyun-oss-wordpress.php b/aliyun-oss-wordpress.php index 690a901..2641d45 100644 --- a/aliyun-oss-wordpress.php +++ b/aliyun-oss-wordpress.php @@ -3,7 +3,7 @@ Plugin Name: OSS Aliyun Plugin URI: https://github.com/sy-records/aliyun-oss-wordpress Description: 使用阿里云对象存储 OSS 作为附件存储空间。(This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.) -Version: 1.1.0 +Version: 1.1.1 Author: 沈唁 Author URI: https://qq52o.me License: Apache 2.0 @@ -14,7 +14,7 @@ require_once 'sdk/vendor/autoload.php'; use OSS\OssClient; use OSS\Core\OssException; -define('OSS_VERSION', "1.1.0"); +define('OSS_VERSION', "1.1.1"); define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__))); // 初始化选项 @@ -196,16 +196,16 @@ function oss_upload_thumbs($metadata) //获取上传路径 $wp_uploads = wp_upload_dir(); $basedir = $wp_uploads['basedir']; + //获取oss插件的配置信息 + $oss_options = get_option('oss_options', true); if (isset($metadata['file'])) { // Maybe there is a problem with the old version $object ='/' . get_option('upload_path') . '/' . $metadata['file']; $file = $basedir . '/' . $metadata['file']; - oss_file_upload($object, $file, oss_is_delete_local_file()); + oss_file_upload($object, $file, (esc_attr($oss_options['nolocalsaving']) == 'true')); } //上传所有缩略图 if (isset($metadata['sizes']) && count($metadata['sizes']) > 0) { - //获取oss插件的配置信息 - $oss_options = get_option('oss_options', true); //是否需要上传缩略图 $nothumb = (esc_attr($oss_options['nothumb']) == 'true'); //如果禁止上传缩略图,就不用继续执行了 diff --git a/readme.txt b/readme.txt index a9c5a1b..701935c 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun Requires at least: 4.2 Tested up to: 5.4 Requires PHP: 5.6.0 -Stable tag: 1.1.0 +Stable tag: 1.1.1 License: Apache 2.0 License URI: http://www.apache.org/licenses/LICENSE-2.0.html @@ -61,8 +61,20 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html 因为Bucket是2019年9月23日后创建的,使用默认域名时会自动下载,需要绑定自有域名访问。具体参考[阿里云文档](https://help.aliyun.com/document_detail/142631.html)。 += 如果存在第三方插件或者主题自带上传功能,内容上传到本地文件夹(即默认wp-content/uploads)中,怎么上传到OSS中? = + +解决方案有两种,推荐使用第二种。 + +一是修改第三方插件或者主题的上传功能,调用插件的`oss_file_upload`方法(不推荐,一般人不会修改) +二是使用对象存储OSS提供的回源功能,配置为镜像方式。如果配置了镜像回源,当用户对该存储空间内一个不存在的文件进行GET操作时,OSS会向回源地址请求这个文件,返回给用户,同时会将该文件存入OSS。这样就达到了上传到OSS的需求。具体配置参考阿里云文档[设置回源规则](https://help.aliyun.com/document_detail/31906.html) + == Changelog == += 1.1.1 = +* 修复本地文件夹为根目录时路径错误 +* 减少一次获取配置代码... +* 增加回源说明 + = 1.1.0 = * 优化删除文件使用删除多个接口 * 修复勾选不在本地保存图片后媒体库显示默认图片问题