Skip to content

Commit

Permalink
🐛 fix(Convert.php): change file type check to extension check to incl…
Browse files Browse the repository at this point in the history
…ude all image types

✨ feat(index.php): remove file extension check in shouldGenerateWebP function
The file type check in Convert.php was changed to an extension check to include all image types. This improves the functionality of the class as it can now process all image types. The file extension check in shouldGenerateWebP function in index.php was removed as it is no longer necessary with the changes made in Convert.php.
  • Loading branch information
MichaelvanLaar committed May 20, 2023
1 parent c4c36ea commit b7e1bdc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@include_once __DIR__ . '/src/webp.php';

function shouldGenerateWebP($file) {
return $file->kirby()->option('kirby3-webp', false) && $file->extension() !== 'svg';
return $file->kirby()->option('kirby3-webp', false);
}

function generateWebP($file) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Convert.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function generateWebP($file)
{
try {
// Checking file type since only images are processed
if ($file->type() == 'image') {
if (in_array($file->extension(), ['jpg', 'jpeg', 'png'])) {
// WebPConvert options
$path = $file->contentFileDirectory() . '/';
$input = $path . $file->filename();
Expand Down

0 comments on commit b7e1bdc

Please sign in to comment.