From b6f136a62e36fea3d5eb87b90efcff5e68c9f81c Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 12 Aug 2020 00:27:13 +0200 Subject: close #124 display video and audio in gallery view --- app/class/Media.php | 20 ++++++++++++-------- app/view/templates/media.php | 21 ++++++++++++++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) (limited to 'app') 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 = '![' . $this->id . '](' . $this->getincludepath() . ')'; + $code = '![' . $this->id . '](' . $src . ')'; break; case 'sound': - $code = '<audio controls src="' . $this->getincludepath() . '"></audio>'; + $code = ''; break; case 'video': - $src = $this->getincludepath(); $ext = $this->extension; - $code = '<video controls="">'; - $code .= '<source src="' . $src . '" type="video/' . $ext . '"></video>'; + $code = ''; 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'
  • @@ -95,7 +110,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' - +
  • @@ -153,7 +168,7 @@ $this->layout('layout', ['title' => 'media', 'stylesheets' => [$css . 'home.css' uid('name') ?> permissions() ?> surface() ?> - +