Support Video Files

This commit is contained in:
seiichiro 2023-12-06 16:40:43 +01:00
parent 9f7c6ebe17
commit 5d4da4b173
6 changed files with 28 additions and 1 deletions

View file

@ -230,6 +230,18 @@ input[type=checkbox]{
height: 100%; height: 100%;
} }
.content-single .single-video {
object-fit: contain;
grid-column: 1 / 4;
grid-row: 1 / 2;
}
.content-single .single-video video {
width: 100%;
height: auto;
max-height: 100%;
}
/* Clickable Areas in Single Image View */ /* Clickable Areas in Single Image View */
.content-single .clickable { .content-single .clickable {
position: relative; position: relative;

BIN
img/video.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

BIN
img/video.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View file

@ -73,7 +73,7 @@ if (isset($_SESSION[$cdir])
$rmdirs[] = '..'; $rmdirs[] = '..';
$files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), $rmdirs); $files = array_diff(scandir($imagedir.$dir, SCANDIR_SORT_DESCENDING), $rmdirs);
// Filter Unsupported Files // Filter Unsupported Files
$files = array_values(preg_grep('/.*\.(?!(webm|sh)).*/i', $files)); $files = array_values(preg_grep('/.*\.(?!(db|sh)).*/i', $files));
$_SESSION[$cdir]['f'] = isset($files) ? $files : null; $_SESSION[$cdir]['f'] = isset($files) ? $files : null;
$_SESSION[$cdir]['d'] = isset($dirs) ? $dirs : null; $_SESSION[$cdir]['d'] = isset($dirs) ? $dirs : null;
$_SESSION[$cdir]['t'] = time(); $_SESSION[$cdir]['t'] = time();
@ -162,6 +162,7 @@ if (!empty($curfiles)| !empty($dirs)) {
foreach ($curfiles as $index => $image) { foreach ($curfiles as $index => $image) {
$data['imageurl'] = str_replace("'", "'", $imageurl.$dir.'/'.$image); $data['imageurl'] = str_replace("'", "'", $imageurl.$dir.'/'.$image);
$data['imagename'] = $image; $data['imagename'] = $image;
$data['filetype'] = mime_content_type(Helpers::end_dir($imagedir.$dir).$image);
$data['tags'] = array_filter(explode(" ", pathinfo(trim(strstr(strtolower($image), ' - '), " -"))['filename'])); $data['tags'] = array_filter(explode(" ", pathinfo(trim(strstr(strtolower($image), ' - '), " -"))['filename']));
} }
Template::view('tpl/single.html', $data); Template::view('tpl/single.html', $data);

View file

@ -37,6 +37,12 @@ class thumb {
$dstpath = $this->thumbdir.$dstname.'.jpg'; $dstpath = $this->thumbdir.$dstname.'.jpg';
if (!file_exists($dstpath)) { if (!file_exists($dstpath)) {
if(str_starts_with(mime_content_type($src), 'video/')) {
error_log("$src: Video File");
return "img/video.png";
}
$type = exif_imagetype($src); $type = exif_imagetype($src);
if ($type == 0) { if ($type == 0) {
error_log("$src: Unknown Image Type"); error_log("$src: Unknown Image Type");

View file

@ -10,9 +10,17 @@
{% else: %} {% else: %}
<div class="content-single notags"> <div class="content-single notags">
{% endif %} {% endif %}
{% if(str_starts_with($filetype, 'video/')): %}
<div class="single-video">
<video controls muted loop>
<source src='{{ $imageurl }}' type='{{ $filetype }}'>
</video>
</div>
{% else: %}
<div class="single-image"> <div class="single-image">
<img src='{{ $imageurl }}' title="{{ $page }}/{{ $last_page }}" /> <img src='{{ $imageurl }}' title="{{ $page }}/{{ $last_page }}" />
</div> </div>
{% endif %}
{% if ($page > 1): %} {% if ($page > 1): %}
<a id="link-prev" class="clickable clickable-left" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $prev_page }}&s=1&gs={{ $gallery_slice }}{{ $filter }}"> <a id="link-prev" class="clickable clickable-left" href="/index.php?d={{ $dir }}&so={{ $sort }}&p={{ $prev_page }}&s=1&gs={{ $gallery_slice }}{{ $filter }}">
<div></div> <div></div>