diff --git a/aliyun-oss-wordpress.php b/aliyun-oss-wordpress.php index eaa4236..bbd3c27 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.4.4 +Version: 1.4.6 Author: 沈唁 Author URI: https://qq52o.me License: Apache2.0 @@ -20,7 +20,7 @@ use OSS\Credentials\CredentialsProvider; use AlibabaCloud\Credentials\Credential; use OSS\Credentials\StaticCredentialsProvider; -define('OSS_VERSION', '1.4.4'); +define('OSS_VERSION', '1.4.6'); define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__))); if (!function_exists('get_home_path')) { @@ -251,6 +251,10 @@ function oss_upload_attachments($metadata) */ function oss_upload_thumbs($metadata) { + if (empty($metadata['file'])) { + return $metadata; + } + //获取上传路径 $wp_uploads = wp_upload_dir(); $basedir = $wp_uploads['basedir']; @@ -261,22 +265,20 @@ function oss_upload_thumbs($metadata) $no_local_file = esc_attr($oss_options['nolocalsaving']) == 'true'; $no_thumb = esc_attr($oss_options['nothumb']) == 'true'; - if (!empty($metadata['file'])) { - // Maybe there is a problem with the old version - $file = $basedir . '/' . $metadata['file']; - if ($upload_path != '.') { - $path_array = explode($upload_path, $file); - if (count($path_array) >= 2) { - $object = '/' . $upload_path . end($path_array); - } - } else { - $object = '/' . $metadata['file']; - $file = str_replace('./', '', $file); + // Maybe there is a problem with the old version + $file = $basedir . '/' . $metadata['file']; + if ($upload_path != '.') { + $path_array = explode($upload_path, $file); + if (count($path_array) >= 2) { + $object = '/' . $upload_path . end($path_array); } - - oss_file_upload($object, $file, $no_local_file); + } else { + $object = '/' . $metadata['file']; + $file = str_replace('./', '', $file); } + oss_file_upload($object, $file, $no_local_file); + //得到本地文件夹和远端文件夹 $dirname = dirname($metadata['file']); $file_path = $dirname != '.' ? "{$basedir}/{$dirname}/" : "{$basedir}/"; diff --git a/readme.txt b/readme.txt index 1348f55..6368502 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun Requires at least: 4.2 Tested up to: 6.3 Requires PHP: 7.0 -Stable tag: 1.4.5 +Stable tag: 1.4.6 License: Apache2.0 License URI: http://www.apache.org/licenses/LICENSE-2.0.html @@ -73,6 +73,10 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html == Changelog == += 1.4.6 = + +- 修复 pdf 等文件格式上传时报错 + = 1.4.5 = - 兼容 PHP 7.0