Skip to content

Commit 4b4b618

Browse files
authored
Merge pull request #11 from maximehuran/feature/add-image-type-management
Add image mime types
2 parents 1f82bd8 + e683af1 commit 4b4b618

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Helper/FileHelperInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ interface FileHelperInterface
4343
'image/gif',
4444
'image/jpeg',
4545
'image/png',
46+
'image/svg+xml',
47+
'image/webp',
48+
'image/avif',
4649
];
4750

4851
public const VIDEO_TYPE_MIMES = [
@@ -61,6 +64,7 @@ interface FileHelperInterface
6164
'image/vnd.microsoft.icon',
6265
'image/x-icon',
6366
'image/ico',
67+
'image/svg+xml',
6468
'image/gif',
6569
'image/jpeg',
6670
'image/png',

src/Resources/views/Admin/MediaManager/Modal/Content/Files/_previewFile.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{% set filePath = folder is not empty ? folder ~ '/' ~ file.path : file.path %}
2-
{% if file.isImage %}
2+
{% if file.isImage and file.mimeType != 'image/svg+xml' %}
33
<a href="/media/{{ filePath }}" target="_blank" rel="noopener noreferrer">
44
<img src="{{ filePath|imagine_filter('monsieurbiz_sylius_media_manager_uploaded_image') }}" alt="{{ filePath|escape('html_attr') }}" style="max-width: 300px;max-height: 30px;" />
55
</a>
6+
{% elseif file.isImage and file.mimeType == 'image/svg+xml' %}
7+
<a href="/media/{{ filePath }}" target="_blank" rel="noopener noreferrer">
8+
<img src="/media/{{ filePath }}" alt="{{ filePath|escape('html_attr') }}" style="max-width: 300px;max-height: 30px;" />
9+
</a>
610
{% elseif file.isFile %}
711
<a href="/media/{{ filePath }}" target="_blank" rel="noopener noreferrer" class="ui button mini icon">
812
<i class="eye icon"></i>

0 commit comments

Comments
 (0)