[GSFile] Fix sanitize configuration

This commit is contained in:
2021-09-22 15:04:45 +01:00
parent c1e7d486a3
commit 7beb5c2995
10 changed files with 96 additions and 98 deletions

View File

@@ -55,6 +55,22 @@ class VideoEncoder extends Plugin
return '1.0.0';
}
/**
* @param array $event_map
* @param string $mimetype
*
* @return bool
*/
public function onFileMetaAvailable(array &$event_map, string $mimetype): bool
{
if (GSFile::mimetypeMajor($mimetype) !== 'video' && $mimetype !== 'image/gif') {
return Event::next;
}
$event_map['video'][] = [$this, 'fileMeta'];
$event_map['image/gif'][] = [$this, 'fileMeta'];
return Event::next;
}
/**
* @param array $event_map
* @param string $mimetype
@@ -66,8 +82,8 @@ class VideoEncoder extends Plugin
if (GSFile::mimetypeMajor($mimetype) !== 'video' && $mimetype !== 'image/gif') {
return Event::next;
}
$event_map['video'][] = [$this, 'fileSanitize'];
$event_map['image/gif'][] = [$this, 'fileSanitize'];
$event_map['video'][] = [$this, 'fileMeta'];
$event_map['image/gif'][] = [$this, 'fileMeta'];
return Event::next;
}
@@ -97,7 +113,7 @@ class VideoEncoder extends Plugin
*
* @return bool true if sanitized
*/
public function fileSanitize(SplFileInfo &$file, ?string &$mimetype, ?int &$width, ?int &$height): bool
public function fileMeta(SplFileInfo &$file, ?string &$mimetype, ?int &$width, ?int &$height): bool
{
if (//GSFile::mimetypeMajor($mimetype) !== 'video' &&
$mimetype !== 'image/gif') {

View File

@@ -1,6 +1,6 @@
<div>
<figure>
<video class="u-video" src="{{ attachment.getUrl() }}" controls poster="{{ attachment.getThumbnailUrl()}}">
<video class="u-video" src="{{ attachment.getUrl() }}" controls poster="{{ attachment.getThumbnailUrl('medium')}}">
</video>
<figcaption><a
href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>