From ae28116ac0093c4fd46ffbdc0389ebfa91277e44 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Fri, 31 Dec 2021 01:41:04 +0900 Subject: [PATCH] Fix #1816 allow images of at least 100x100px when creating large thumbnails --- modules/comment/comment.item.php | 4 +++- modules/document/document.item.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php index 5b9931027..2bfd2b028 100644 --- a/modules/comment/comment.item.php +++ b/modules/comment/comment.item.php @@ -790,6 +790,8 @@ class commentItem extends BaseObject // get an image file from the doc content if no file attached. if(!$source_file && $config->thumbnail_target !== 'attachment') { + $external_image_min_width = min(100, round($trigger_obj->width * 0.3)); + $external_image_min_height = min(100, round($trigger_obj->height * 0.3)); preg_match_all("!]*?src=(\"|')([^\"' ]*?)(\"|')!is", $this->get('content'), $matches, PREG_SET_ORDER); foreach($matches as $match) { @@ -820,7 +822,7 @@ class commentItem extends BaseObject if($is_img = @getimagesize($tmp_file)) { list($_w, $_h, $_t, $_a) = $is_img; - if($_w < ($width * 0.3) && ($height === 'auto' || $_h < ($height * 0.3))) + if($_w < ($external_image_min_width) && ($height === 'auto' || $_h < ($external_image_min_height))) { continue; } diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 739c0061e..371467d87 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -1199,6 +1199,8 @@ class documentItem extends BaseObject // If not exists, file an image file from the content if(!$source_file && $config->thumbnail_target !== 'attachment') { + $external_image_min_width = min(100, round($trigger_obj->width * 0.3)); + $external_image_min_height = min(100, round($trigger_obj->height * 0.3)); preg_match_all("!]*?src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER); foreach($matches as $match) { @@ -1229,7 +1231,7 @@ class documentItem extends BaseObject if($is_img = @getimagesize($tmp_file)) { list($_w, $_h, $_t, $_a) = $is_img; - if($_w < ($width * 0.3) && ($height === 'auto' || $_h < ($height * 0.3))) + if($_w < ($external_image_min_width) && ($height === 'auto' || $_h < ($external_image_min_height))) { continue; }