Commit ba395d56 authored by Nicolas Widart's avatar Nicolas Widart

Only return thumbnail path if image

parent 213e9c04
......@@ -69,6 +69,8 @@ class Imagy
*/
public function getThumbnail($originalImage, $thumbnail)
{
if (!$this->isImage($originalImage)) return $originalImage;
return '/assets/media/' . $this->newFilename($originalImage, $thumbnail);
}
......
......@@ -45,4 +45,22 @@ class ImagyTest extends BaseTestCase
$this->assertFalse($this->finder->isFile(public_path() . '/assets/media/test-pdf_smallThumb.png'));
}
/** @test */
public function it_should_return_thumbnail_path()
{
$path = $this->imagy->getThumbnail('/assets/media/google-map.png', 'smallThumb');
$expected = '/assets/media/google-map_smallThumb.png';
$this->assertEquals($expected, $path);
}
/** @test */
public function it_should_return_same_path_for_non_images()
{
$path = $this->imagy->getThumbnail('/assets/media/test-pdf.pdf', 'smallThumb');
$expected = '/assets/media/test-pdf.pdf';
$this->assertEquals($expected, $path);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment