Images processing ignore gif format (#43)

master v1.4.18
Luffy 2024-08-14 10:15:01 +08:00 committed by GitHub
parent 28df5b05f4
commit c8981d2ced
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 4 deletions

View File

@ -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.17
Version: 1.4.18
Author: 沈唁
Author URI: https://qq52o.me
License: Apache2.0
@ -19,7 +19,7 @@ use OSS\Credentials\CredentialsProvider;
use AlibabaCloud\Credentials\Credential;
use OSS\Credentials\StaticCredentialsProvider;
define('OSS_VERSION', '1.4.17');
define('OSS_VERSION', '1.4.18');
define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__)));
if (!function_exists('get_home_path')) {
@ -505,6 +505,9 @@ function oss_custom_image_srcset($sources, $size_array, $image_src, $image_meta,
}
foreach ($sources as $index => $source) {
if (!isset($source['url']) || !oss_is_image_type($source['url'])) {
continue;
}
if (strpos($source['url'], $upload_url_path) !== false && strpos($source['url'], $style) === false) {
$sources[$index]['url'] .= $style;
}
@ -543,6 +546,9 @@ function oss_setting_content_style($content)
if (!empty($images) && isset($images[1])) {
$images[1] = array_unique($images[1]);
foreach ($images[1] as $item) {
if (!oss_is_image_type($item)) {
continue;
}
if (strpos($item, $upload_url_path) !== false && strpos($item, $style) === false) {
$content = str_replace($item, $item . $style, $content);
}
@ -565,6 +571,9 @@ function oss_setting_post_thumbnail_style($html, $post_id, $post_image_id)
if (!empty($images) && isset($images[1])) {
$images[1] = array_unique($images[1]);
foreach ($images[1] as $item) {
if (!oss_is_image_type($item)) {
continue;
}
if (strpos($item, $upload_url_path) !== false && strpos($item, $style) === false) {
$html = str_replace($item, $item . $style, $html);
}
@ -705,7 +714,7 @@ function oss_add_suffix_for_media_send_to_editor($data)
*/
function oss_is_image_type($url)
{
return (bool) preg_match('/\.(jpg|jpeg|jpe|gif|png|bmp|webp|heic|heifsvg)$/i', $url);
return (bool) preg_match('/\.(jpg|jpeg|jpe|png|bmp|webp|heic|heif|svg)$/i', $url);
}
/**

View File

@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun
Requires at least: 4.6
Tested up to: 6.6
Requires PHP: 7.1
Stable tag: 1.4.17
Stable tag: 1.4.18
License: Apache2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html
@ -76,6 +76,10 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Changelog ==
= 1.4.18 =
- Images processing ignore gif format
= 1.4.17 =
- Fix endpoint failed to use https