From e5b41f5bec41333f3b563646c8b859ff8f11483f Mon Sep 17 00:00:00 2001 From: OctaYann Date: Fri, 13 Sep 2024 12:20:33 +0200 Subject: [PATCH] fix: do not get distant image infos to avoid warns --- classes/prettyblocks/core/FieldCore.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/classes/prettyblocks/core/FieldCore.php b/classes/prettyblocks/core/FieldCore.php index 9dba1f2d..319d7eb7 100644 --- a/classes/prettyblocks/core/FieldCore.php +++ b/classes/prettyblocks/core/FieldCore.php @@ -448,27 +448,29 @@ public function formatFieldFileuploadForFront() { $value = $this->formatFieldFileupload(); + $path = $value['url']; $size = 0; $width = 0; $height = 0; if (!empty($value['url'])) { - $path = \HelperBuilder::pathFormattedFromUrl($value['url']); + if (str_contains($value['url'], $_SERVER["HTTP_HOST"])) { + $path = \HelperBuilder::pathFormattedFromUrl($value['url']); - if (file_exists($path)) { - $size = filesize($path); + if (file_exists($path)) { + $size = filesize($path); - // if file is an image, we return width and height - if ($value['mediatype'] == 'image') { - list($width, $height) = getimagesize($path); + // if file is an image, we return width and height + if ($value['mediatype'] == 'image') { + list($width, $height) = getimagesize($path); + } } + $value['size'] = (int) $size; + $value['width'] = (int) $width; + $value['height'] = (int) $height; } } - $value['size'] = (int) $size; - $value['width'] = (int) $width; - $value['height'] = (int) $height; - return $value; }