feat: video playr support in attachments

This commit is contained in:
2026-03-28 19:55:30 +03:00
parent 6051730b8f
commit 07c864b7e9
2 changed files with 34 additions and 0 deletions

View File

@@ -426,6 +426,27 @@ class BBCodeService {
$escapedFileName,
$escapedFileName
);
} elseif (str_starts_with($mimeType, 'video/')) {
// Generate download URL for video (used as source)
$videoUrl = $this->urlGenerator->linkToRouteAbsolute(
'forum.file.download',
['postId' => $postId, 'filePath' => $filePath]
);
$escapedFileName = htmlspecialchars($fileName, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$escapedUrl = htmlspecialchars($videoUrl, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$escapedMimeType = htmlspecialchars($mimeType, ENT_QUOTES | ENT_HTML5, 'UTF-8');
return sprintf(
'<div class="attachment attachment-video">'
. '<video controls preload="metadata" title="%s">'
. '<source src="%s" type="%s" />'
. '</video>'
. '</div>',
$escapedFileName,
$escapedUrl,
$escapedMimeType
);
} else {
// Generate download URL for non-image files using proxy endpoint
$downloadUrl = $this->urlGenerator->linkToRouteAbsolute(

View File

@@ -65,6 +65,19 @@
}
}
&-video {
display: inline-block;
max-width: 100%;
video {
max-width: 100%;
max-height: 480px;
border-radius: 8px;
border: 1px solid var(--color-border);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
}
&-file {
display: flex;
align-items: center;