mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-11 01:35:54 +08:00
Merge 4dbfefddd84e6adfe84e29bf6f276e0ab648c8cf into 802f69cf35abba8ff75b0ef7bbed09bbcda62816
This commit is contained in:
commit
0f69c18709
@ -32,7 +32,7 @@ class ZipExportImage extends ZipExportModel
|
||||
|
||||
public static function validate(ZipValidationHelper $context, array $data): array
|
||||
{
|
||||
$acceptedImageTypes = ['image/png', 'image/jpeg', 'image/gif', 'image/webp'];
|
||||
$acceptedImageTypes = ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/svg+xml'];
|
||||
$rules = [
|
||||
'id' => ['nullable', 'int', $context->uniqueIdRule('image')],
|
||||
'name' => ['required', 'string', 'min:1'],
|
||||
|
@ -163,7 +163,7 @@ abstract class Controller extends BaseController
|
||||
*/
|
||||
protected function getImageValidationRules(): array
|
||||
{
|
||||
return ['image_extension', 'mimes:jpeg,png,gif,webp', 'max:' . (config('app.upload_limit') * 1000)];
|
||||
return ['image_extension', 'mimes:jpeg,png,gif,webp,svg', 'max:' . (config('app.upload_limit') * 1000)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,6 +66,11 @@ class ImageResizer
|
||||
bool $keepRatio = false,
|
||||
bool $shouldCreate = false
|
||||
): ?string {
|
||||
// Do not attempt to resize SVGs, return the raw value always.
|
||||
if ($this->isSvg($image)) {
|
||||
return $this->storage->getPublicUrl($image->path);
|
||||
}
|
||||
|
||||
// Do not resize GIF images where we're not cropping
|
||||
if ($keepRatio && $this->isGif($image)) {
|
||||
return $this->storage->getPublicUrl($image->path);
|
||||
@ -229,6 +234,14 @@ class ImageResizer
|
||||
return $this->getExtension($image) === 'gif';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the image is a svg. Returns true if it is, else false.
|
||||
*/
|
||||
protected function isSvg(Image $image): bool
|
||||
{
|
||||
return $this->getExtension($image) === 'svg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extension for the given image, normalised to lower-case.
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class ImageService
|
||||
{
|
||||
protected static array $supportedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
||||
protected static array $supportedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'];
|
||||
|
||||
public function __construct(
|
||||
protected ImageStorage $storage,
|
||||
|
@ -33,6 +33,7 @@ class WebSafeMimeSniffer
|
||||
'image/webp',
|
||||
'image/avif',
|
||||
'image/heic',
|
||||
'image/svg+xml',
|
||||
'text/css',
|
||||
'text/csv',
|
||||
'text/javascript',
|
||||
|
Loading…
x
Reference in New Issue
Block a user