diff options
Diffstat (limited to 'app/class/Media.php')
-rw-r--r-- | app/class/Media.php | 20 |
1 files changed, 12 insertions, 8 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; } |