Skip to content

Commit

Permalink
Fix problem with uppercase extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrckvzn committed Nov 8, 2021
1 parent 20d2997 commit 6be42f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion resources/views/picture.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@isset($sources)
@foreach($sources as $source)
<source
@if(config('twill-image.webp_support'))
@if(isset($source['type']) && config('twill-image.webp_support'))
type="{{ $source['type'] }}"
@endif
@if(isset($source['mediaQuery']))
Expand Down
6 changes: 4 additions & 2 deletions src/ViewModels/ImageViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ protected function buildSourceObject($srcSet, $aspectRatio, $type = null, $media

protected function mimeType($extension)
{
$ext = strtolower($extension);

$types = [
'png' => 'image/png',
'jpe' => 'image/jpeg',
Expand All @@ -257,8 +259,8 @@ protected function mimeType($extension)
'webp' => 'image/webp',
];

if (isset($types[$extension])) {
return $types[$extension];
if (isset($types[$ext])) {
return $types[$ext];
}

return null;
Expand Down

0 comments on commit 6be42f4

Please sign in to comment.