From 71f05e64b3b1359fad8a421e5f2171dbbae4a3a8 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Fri, 3 Apr 2020 08:24:01 +0800 Subject: [PATCH] update version to 1.0.1 --- aliyun-oss-wordpress.php | 25 ++++++++----------------- readme.txt | 7 +++++-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/aliyun-oss-wordpress.php b/aliyun-oss-wordpress.php index 1594aca..1dce818 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.0.0 +Version: 1.0.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.0.0"); +define('OSS_VERSION', "1.0.1"); define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__))); // 初始化选项 @@ -67,7 +67,7 @@ function oss_get_bucket_name() * @param $opt * @return bool */ -function oss_file_upload($object, $file) +function oss_file_upload($object, $file, $no_local_file = false) { //如果文件不存在,直接返回false if (!@file_exists($file)) { @@ -81,6 +81,9 @@ function oss_file_upload($object, $file) // echo 'Error Message:' . $e->getMessage() . PHP_EOL; // echo 'Error Code:' . $e->getCode() . PHP_EOL; } + if ($no_local_file) { + oss_delete_local_file($file); + } } /** @@ -151,12 +154,8 @@ function oss_upload_attachments($metadata) $file = get_home_path() . $object; //向上兼容,较早的WordPress版本上$metadata['file']存放的是相对路径 //执行上传操作 - oss_file_upload('/' . $object, $file); + oss_file_upload('/' . $object, $file, oss_is_delete_local_file()); - //如果不在本地保存,则删除本地文件 - if (oss_is_delete_local_file()) { - oss_delete_local_file($file); - } return $metadata; } @@ -176,8 +175,6 @@ function oss_upload_thumbs($metadata) $oss_options = get_option('oss_options', true); //是否需要上传缩略图 $nothumb = (esc_attr($oss_options['nothumb']) == 'true'); - //是否需要删除本地文件 - $is_delete_local_file = (esc_attr($oss_options['nolocalsaving']) == 'true'); //如果禁止上传缩略图,就不用继续执行了 if ($nothumb) { return $metadata; @@ -205,13 +202,7 @@ function oss_upload_thumbs($metadata) $file = $file_path . $val['file']; //执行上传操作 - oss_file_upload($object, $file); - - //如果不在本地保存,则删除 - if ($is_delete_local_file) { - oss_delete_local_file($file); - } - + oss_file_upload($object, $file, (esc_attr($oss_options['nolocalsaving']) == 'true')); } } return $metadata; diff --git a/readme.txt b/readme.txt index 3fe4706..568421d 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: shenyanzhi Donate link: https://qq52o.me/sponsor.html Tags: oss, 阿里云, 对象存储, aliyun Requires at least: 4.2 -Tested up to: 5.3.2 +Tested up to: 5.4 Requires PHP: 5.6.0 -Stable tag: 1.0.0 +Stable tag: 1.0.1 License: Apache 2.0 License URI: http://www.apache.org/licenses/LICENSE-2.0.html @@ -59,5 +59,8 @@ QQ交流群:887595381 == Changelog == += 1.0.1 = +* 修复勾选不在本地保存图片后媒体库显示默认图片问题 + = 1.0 = * First version