Add video support

This commit is contained in:
Dominic Ferrando
2025-04-22 00:06:11 -04:00
parent fac517b28d
commit 741ac24e3e
15 changed files with 236 additions and 102 deletions
+8
View File
@@ -220,6 +220,14 @@ body {
max-width: 100%;
}
.post-vid {
display: block;
float: left;
margin: 4px 12px 4px 0;
height: auto;
max-width: 100%;
}
.post-img-info {
display: inline-block;
font-size: 10px;

Before

Width:  |  Height:  |  Size: 213 KiB

After

Width:  |  Height:  |  Size: 213 KiB

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

+24 -7
View File
@@ -36,15 +36,32 @@ function insertHeaderReplies() {
}
}
function togglePostImage(img) {
const filename = img.src.split("/").at(-1);
if (img.classList.contains("post-img-full")) {
img.classList.remove("post-img-full");
img.src = "/static/img/posts/thumb/" + filename;
function togglePostFile(imgEl) {
const isVideo = imgEl.dataset.full.endsWith(".mp4") || imgEl.dataset.full.endsWith(".webm") || imgEl.dataset.full.endsWith(".ogg");
if (isVideo) {
const vidEl = imgEl.parentElement.querySelector("video");
if (vidEl.style.display === "none") {
vidEl.src = "/static/media/posts/full/" + imgEl.dataset.full;
vidEl.style.display = "";
imgEl.style.display = "none";
}
else {
vidEl.src = "";
vidEl.style.display = "none";
imgEl.style.display = "";
}
}
else {
img.classList.add("post-img-full");
img.src = "/static/img/posts/full/" + filename;
if (imgEl.classList.contains("post-img-full")) {
imgEl.classList.remove("post-img-full");
imgEl.src = "/static/media/posts/thumb/" + imgEl.dataset.thumb;
}
else {
imgEl.classList.add("post-img-full");
imgEl.src = "/static/media/posts/full/" + imgEl.dataset.full;
}
}
}