Skip to content

Commit 0c742d3

Browse files
authored
Merge pull request #127 from iMattPro/fix-107
Handle webp like other image files
2 parents c1f1dfc + 49a348d commit 0c742d3

File tree

8 files changed

+25
-0
lines changed

8 files changed

+25
-0
lines changed

src/Files/FileLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private function tryLoadFile($fileName, $extension)
184184
case 'jpg':
185185
case 'jpeg':
186186
case 'svg':
187+
case 'webp':
187188
return new ImageFile($this->debug, $fileName, $this->rundir);
188189

189190
case 'swf':

tests/file_loader_test.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
use Phpbb\Epv\Files\FileLoader;
12+
use Phpbb\Epv\Files\Type\ImageFile;
1213
use Phpbb\Epv\Files\Type\LangFile;
1314
use Phpbb\Epv\Files\Type\MigrationFile;
1415
use Phpbb\Epv\Files\Type\PHPFile;
@@ -67,4 +68,23 @@ public function test_file_empty_yml()
6768
$emptyYml = static::$loader->loadFile('tests/testFiles/empty.yml');
6869
self::assertNull($emptyYml);
6970
}
71+
72+
public function test_file_image()
73+
{
74+
$images = [
75+
'gif' => 'image.gif',
76+
'png' => 'image.png',
77+
'svg' => 'image.svg',
78+
'jpg' => 'image.jpg',
79+
'jpeg' => 'image.jpeg',
80+
'webp' => 'image.webp'
81+
];
82+
83+
foreach ($images as $image)
84+
{
85+
$img = static::$loader->loadFile('tests/testFiles/images/' . $image);
86+
self::assertInstanceOf(ImageFile::class, $img);
87+
88+
}
89+
}
7090
}

tests/testFiles/images/image.gif

61 Bytes
Loading

tests/testFiles/images/image.jpeg

4.11 KB
Loading

tests/testFiles/images/image.jpg

4.11 KB
Loading

tests/testFiles/images/image.png

3.49 KB
Loading

tests/testFiles/images/image.svg

Lines changed: 4 additions & 0 deletions
Loading

tests/testFiles/images/image.webp

58 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)