diff --git a/README.md b/README.md index bed166d..c0f7a96 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Image Extension for Mecha Release Notes ------------- +### 2.2.5 + + - Small bug fixes. + ### 2.2.4 - Fix encoded data image URL being passed to the `imagecreatefromstring()` without decoding it first. diff --git a/image/about.page b/image/about.page index 1bd874d..71c23a3 100644 --- a/image/about.page +++ b/image/about.page @@ -3,7 +3,7 @@ title: Image description: Image resizer and cropper. author: Taufik Nurrohman type: Markdown -version: 2.2.4 +version: 2.2.5 use: '.\lot\x\page': 0 diff --git a/image/engine/kernel/g-d.image.php b/image/engine/kernel/g-d.image.php index 9719d73..63282d3 100644 --- a/image/engine/kernel/g-d.image.php +++ b/image/engine/kernel/g-d.image.php @@ -106,8 +106,17 @@ public function __construct(string $path = null) { // Create image from local file } else if (\is_file($path)) { $type = \mime_content_type($path); - if (0 === \strpos($type, 'image/') && \function_exists($fn = $from . \pathinfo($path, \PATHINFO_EXTENSION))) { - $blob = \call_user_func($fn, $path); + if (0 === \strpos($type, 'image/')) { + // Try with image type by default + if (\function_exists($fn = $from . \explode('/', $type, 2)[1])) { + $blob = \call_user_func($fn, $path); + } + // Try with image extension if `$blob` is `false` + if (!$blob && \function_exists($fn = $from . \pathinfo($path, \PATHINFO_EXTENSION))) { + $blob = \call_user_func($fn, $path); + } + // Last try? + if (!$blob) {} } $this->exist = true; $this->path = $path;