diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-08-12 00:27:13 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-08-12 00:27:13 +0200 |
commit | b6f136a62e36fea3d5eb87b90efcff5e68c9f81c (patch) | |
tree | 2e89094ac1898cdc158bfe3b60c6db293324005b /app | |
parent | c18f64265a4521c3cd3f7f52c37461c1beff34b4 (diff) | |
download | wcms-b6f136a62e36fea3d5eb87b90efcff5e68c9f81c.tar.gz wcms-b6f136a62e36fea3d5eb87b90efcff5e68c9f81c.zip |
close #124 display video and audio in gallery view
Diffstat (limited to 'app')
-rw-r--r-- | app/class/Media.php | 20 | ||||
-rw-r--r-- | app/view/templates/media.php | 21 |
2 files changed, 30 insertions, 11 deletions
diff --git a/app/class/Media.php b/app/class/Media.php index 1a1e54a..8ecc872 100644 --- a/app/class/Media.php +++ b/app/class/Media.php @@ -86,29 +86,33 @@ class Media extends Item /** * Generate html code depending on media type - * + * @param bool $fullpath option to use fullpath of file instead of W rendered one. default is false * @return string html code */ - public function getcode(): string + public function getcode($fullpath = false): string { + if ($fullpath === true) { + $src = $this->getfullpath(); + } else { + $src = $this->getincludepath(); + } + switch ($this->type) { case 'image': - $code = ' . ')'; + $code = ''; break; case 'sound': - $code = '<audio controls src="' . $this->getincludepath() . '"></audio>'; + $code = '<audio controls src="' . $src . '"></audio>'; break; case 'video': - $src = $this->getincludepath(); $ext = $this->extension; - $code = '<video controls="">'; - $code .= '<source src="' . $src . '" type="video/' . $ext . '"></video>'; + $code = '<video controls=""><source src="' . $src . '" type="video/' . $ext . '"></video>'; break; default: - $code = '[' . $this->id . '](' . $this->getincludepath() . ')'; + $code = '[' . $this->id . '](' . $src . ')'; break; } diff --git a/app/view/templates/media.php b/app/view/templates/media.php index 42654db..a8b7157 100644 --- a/app/view/templates/media.php +++ b/app/view/templates/media.php @@ -87,7 +87,22 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' <li title="<?= $media->size('hr') ?> | <?= $media->uid('name') ?> | <?= $media->permissions() ?>"> <div class="thumbnail"> <label for="media_<?= $media->id() ?>"> - <?= $media->type() == 'image' ? '<img src="' . $media->getfullpath() . '">' : $media->getsymbol() ?> + <?php + switch ($media->type()) { + case 'image': + echo '<img src="' . $media->getfullpath() . '">'; + break; + + case 'video': + case 'sound': + echo $media->getcode(true); + break; + + default: + echo $media->getsymbol(true); + break; + } + ?> </label> </div> @@ -95,7 +110,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' <input type="checkbox" name="id[]" value="<?= $media->getfulldir() ?>" form="mediaedit" id="media_<?= $media->id() ?>"> <label for="media_<?= $media->id() ?>"><?= $media->id() ?></label> <a href="<?= $media->getfullpath() ?>" target="_blank">⧉</a> - <input readonly class="code select-all" value="<?= $media->getcode() ?>" /> + <input readonly class="code select-all" value="<?= $this->e($media->getcode()) ?>" /> </div> </li> @@ -153,7 +168,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' <td><?= $media->uid('name') ?></td> <td><code><?= $media->permissions() ?></code></td> <td><?= $media->surface() ?></td> - <td><input readonly class="code select-all" value="<?= $media->getcode() ?>" /></td> + <td><input readonly class="code select-all" value="<?= $this->e($media->getcode()) ?>" /></td> </tr> <?php } |