Skip to content

Commit

Permalink
Allow PDF files for the thumbnail generation (#1297)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-gupta authored Sep 16, 2020
1 parent 93ca0f4 commit d2ec6d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Imagine/Data/DataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ public function find($filter, $path)
throw new LogicException(sprintf('The mime type of image %s was not guessed.', $path));
}

if (0 !== mb_strpos($binary->getMimeType(), 'image/')) {
throw new LogicException(sprintf('The mime type of image %s must be image/xxx got %s.', $path, $binary->getMimeType()));
if (0 !== mb_strpos($binary->getMimeType(), 'image/') && $binary->getMimeType() !== 'application/pdf') {
throw new LogicException(sprintf('The mime type of file %s must be image/xxx or application/pdf, got %s.', $path, $binary->getMimeType()));
}

return $binary;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Imagine/Data/DataManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function testThrowsIfMimeTypeWasNotGuessedOnFind(): void
public function testThrowsIfMimeTypeNotImageOneOnFind(): void
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The mime type of image cats.jpeg must be image/xxx got text/plain');
$this->expectExceptionMessage('The mime type of file cats.jpeg must be image/xxx or application/pdf, got text/plain');

$loader = $this->createBinaryLoaderInterfaceMock();
$loader
Expand Down Expand Up @@ -197,7 +197,7 @@ public function testThrowsIfLoaderReturnBinaryWithEmtptyMimeTypeOnFind(): void
public function testThrowsIfLoaderReturnBinaryWithMimeTypeNotImageOneOnFind(): void
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The mime type of image cats.jpeg must be image/xxx got text/plain');
$this->expectExceptionMessage('The mime type of file cats.jpeg must be image/xxx or application/pdf, got text/plain');

$binary = new Binary('content', 'text/plain');

Expand Down

0 comments on commit d2ec6d5

Please sign in to comment.