Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Oct 27, 2024
1 parent d622476 commit de62884
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion docs/3.0/config/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/Api/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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';

Check failure on line 121 in src/Api/Encoder.php

View workflow job for this annotation

GitHub Actions / psalm

RiskyTruthyFalsyComparison

src/Api/Encoder.php:121:16: RiskyTruthyFalsyComparison: Operand of type false|string contains type string, which can be falsy and truthy. This can cause possibly unexpected behavior. Use strict comparison instead. (see https://psalm.dev/356)
}

/**
* Get a list of supported image formats and MIME types.
*
Expand Down

0 comments on commit de62884

Please sign in to comment.