mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 19:28:51 +02:00
Treat all image formats that browsers can show correctly as image attachments.
Especially we can now use WebP for attachments.
This commit is contained in:
parent
e4f5afb628
commit
e78033d774
1 changed files with 10 additions and 4 deletions
|
@ -40,6 +40,15 @@ use Doctrine\ORM\Mapping as ORM;
|
||||||
*/
|
*/
|
||||||
abstract class Attachment extends NamedDBElement
|
abstract class Attachment extends NamedDBElement
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of file extensions, that browsers can show directly as image.
|
||||||
|
* Based on: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
||||||
|
* It will be used to determine if a attachment is a picture and therefore will be shown to user as preview.
|
||||||
|
*/
|
||||||
|
const PICTURE_EXTS = ['apng', 'bmp', 'gif', 'ico', 'cur', 'jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp', 'png',
|
||||||
|
'svg', 'webp'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
* @ORM\Column(type="boolean")
|
* @ORM\Column(type="boolean")
|
||||||
|
@ -85,10 +94,7 @@ abstract class Attachment extends NamedDBElement
|
||||||
|
|
||||||
$extension = pathinfo($this->getPath(), PATHINFO_EXTENSION);
|
$extension = pathinfo($this->getPath(), PATHINFO_EXTENSION);
|
||||||
|
|
||||||
// list all file extensions which are supported to display them by HTML code
|
return in_array(strtolower($extension), static::PICTURE_EXTS, true);
|
||||||
$picture_extensions = array('gif', 'png', 'jpg', 'jpeg', 'bmp', 'svg', 'tif');
|
|
||||||
|
|
||||||
return in_array(strtolower($extension), $picture_extensions, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue