From 7171827c725d50cd722a8789b25cc4cf05867c24 Mon Sep 17 00:00:00 2001 From: BigKev73 <77700018+BigKev73@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:50:23 -0600 Subject: [PATCH] Update functions.image.php Changes to fix logic issues with creating thumbnails, setting the thumbnail path and setting the img_info string --- include/functions.image.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/functions.image.php b/include/functions.image.php index 00fe447b..6467823c 100644 --- a/include/functions.image.php +++ b/include/functions.image.php @@ -50,9 +50,10 @@ function newbbAttachmentImage($source) $img_info = ''; $imginfo = @getimagesize($image); - if (is_array($image)) { + // Change by BigKev73 - Removed the is_array check, otherwise the img_info is never set + //if (is_array($image)) { $img_info = (count($imginfo) > 0) ? $imginfo[0] . 'X' . $imginfo[1] . ' px' : ''; - } + //} if ($GLOBALS['xoopsModuleConfig']['max_image_width'] > 0 && $GLOBALS['xoopsModuleConfig']['max_image_height'] > 0) { @@ -63,7 +64,10 @@ function newbbAttachmentImage($source) newbbCreateThumbnail($source, $GLOBALS['xoopsModuleConfig']['max_image_width']); } } - + } + + // Change by BigKev73 - moved this outside the above logic, or this never get sets if thumbnails dont get created + if ($imginfo[0] > $GLOBALS['xoopsModuleConfig']['max_image_width'] || $imginfo[1] > $GLOBALS['xoopsModuleConfig']['max_image_height']) { $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_width']; @@ -77,12 +81,13 @@ function newbbAttachmentImage($source) $pseudo_width = $GLOBALS['xoopsModuleConfig']['max_image_height'] * ($imginfo[0] / $imginfo[1]); $pseudo_size = "width='" . $pseudo_width . "px' height='" . $pseudo_height . "px'"; } - } + if (file_exists($thumb)) { $attachmentImage = ''; - // $attachmentImage .= '' . $source . ' ' . $img_info . ''; - $attachmentImage .= '' . $source . ' ' . $img_info . ''; + // Change by BigKev73 - Changed this code back or thumbnails never get displayed, even if they got created ok + $attachmentImage .= '' . $source . ' ' . $img_info . ''; + // $attachmentImage .= '' . $source . ' ' . $img_info . ''; $attachmentImage .= ''; } elseif (!empty($pseudo_size)) { $attachmentImage = '';