diff --git a/docs/3.0/config/setup.md b/docs/3.0/config/setup.md index f52e2129..e94728ad 100644 --- a/docs/3.0/config/setup.md +++ b/docs/3.0/config/setup.md @@ -77,7 +77,6 @@ $manipulators = [ new League\Glide\Manipulators\Watermark($watermarks), new League\Glide\Manipulators\Background(), new League\Glide\Manipulators\Border(), - new League\Glide\Manipulators\Encode(), ]; // Set API diff --git a/src/Api/Encoder.php b/src/Api/Encoder.php index bef473b2..7c1c140e 100644 --- a/src/Api/Encoder.php +++ b/src/Api/Encoder.php @@ -87,7 +87,7 @@ public function run(ImageInterface $image): EncodedImageInterface throw new \Exception("Invalid format provided: {$format}"); } - return $image->encodeByExtension(...$encoderOptions); + return $image->encodeByMediaType(...$encoderOptions); } /** @@ -109,6 +109,18 @@ public function getFormat(ImageInterface $image): string return array_search($image->origin()->mediaType(), static::supportedFormats(), true) ?: 'jpg'; } + public function getMimeType(ImageInterface $image): string + { + $formats = static::supportedFormats(); + + $fm = (string) $this->getParam('fm'); + if ($fm && isset($formats[$fm])) { + return $formats[$fm]; + } + + return array_search($image->origin()->mediaType(), static::supportedFormats(), true) ?: 'image/jpeg'; + } + /** * Get a list of supported image formats and MIME types. *