Skip to content

Commit f0c12d5

Browse files
author
Bradie Tilley
committed
Improvement to the detection of the original image's mime type (uses less system resources)
1 parent 97d8542 commit f0c12d5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

classes/Resizer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use File;
1111
use Intervention\Image\ImageManagerStatic as Image;
1212
use Validator;
13+
use Illuminate\Support\Str;
1314

1415
class Resizer
1516
{
@@ -690,11 +691,8 @@ private function detectFormat(bool $useNewFormat = false): array
690691
if ($useNewFormat && !empty($this->options['format']) && ($this->options['format'] !== 'auto')) {
691692
$format = $this->options['format'];
692693
} else {
693-
// Get the image resource entity if not already loaded
694-
$this->initResource();
695-
696-
// Get format from image
697-
$format = strtolower(explode('/', $this->original->mime())[1]);
694+
$format = File::mimeType($this->getImagePath());
695+
$format = Str::after($format, '/');
698696
}
699697

700698
// For the most part, the mime is the format: image/{format}

updates/version.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040
2.1.7:
4141
- Fix - Update plugin's boot method to not directly reference Settings until DB connection is established
4242
2.1.8:
43-
- Added twig filter to parse and resize/modify images (via regex) using twig filter(s)
43+
- Added twig filter to parse and resize/modify images (via regex) using twig filter(s)
44+
2.1.9:
45+
- Improvement to the detection of the original image's mime type (uses less system resources)

0 commit comments

Comments
 (0)