aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-08-12 00:27:13 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-08-12 00:27:13 +0200
commitb6f136a62e36fea3d5eb87b90efcff5e68c9f81c (patch)
tree2e89094ac1898cdc158bfe3b60c6db293324005b /app/class
parentc18f64265a4521c3cd3f7f52c37461c1beff34b4 (diff)
downloadwcms-b6f136a62e36fea3d5eb87b90efcff5e68c9f81c.tar.gz
wcms-b6f136a62e36fea3d5eb87b90efcff5e68c9f81c.zip
close #124 display video and audio in gallery view
Diffstat (limited to 'app/class')
-rw-r--r--app/class/Media.php20
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 = '![' . $this->id . '](' . $this->getincludepath() . ')';
+ $code = '![' . $this->id . '](' . $src . ')';
break;
case 'sound':
- $code = '&lt;audio controls src=&quot;' . $this->getincludepath() . '&quot;&gt;&lt;/audio&gt;';
+ $code = '<audio controls src="' . $src . '"></audio>';
break;
case 'video':
- $src = $this->getincludepath();
$ext = $this->extension;
- $code = '&lt;video controls=&quot;&quot;&gt;';
- $code .= '&lt;source src=&quot;' . $src . '&quot; type=&quot;video/' . $ext . '&quot;&gt;&lt;/video&gt;';
+ $code = '<video controls=""><source src="' . $src . '" type="video/' . $ext . '"></video>';
break;
default:
- $code = '[' . $this->id . '](' . $this->getincludepath() . ')';
+ $code = '[' . $this->id . '](' . $src . ')';
break;
}