summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/media.php12
-rw-r--r--inc/parser/xhtml.php10
2 files changed, 16 insertions, 6 deletions
diff --git a/inc/media.php b/inc/media.php
index c1dafe2a3..6d0615a3c 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -2136,12 +2136,13 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x=
* Return other media files with the same base name
* but a different extension.
*
- * @param string $src - ID of media file
- * @param array $exts - alternative extensions to find other files for
+ * @param string $src - ID of media file
+ * @param array $exts - alternative extensions to find other files for
+ * @param boolean $onlyone - set if only one result should be returned (and not the original)
*
* @author Anika Henke <anika@selfthinker.org>
*/
-function media_alternativefiles($src, $exts){
+function media_alternativefiles($src, $exts, $onlyone=false){
$files = array();
list($srcExt, $srcMime) = mimetype($src);
@@ -2152,10 +2153,13 @@ function media_alternativefiles($src, $exts){
$file = mediaFN($fileid);
if(file_exists($file)) {
$files[$ext] = $fileid;
+ if ($onlyone) {
+ return $files;
+ }
}
}
// if original wasn't any of $exts, return only original
- if (empty($files)) {
+ if (empty($files) && !$onlyone) {
$files[$srcExt] = $src;
}
return $files;
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index bb5f6a4d2..8b7405402 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -1278,9 +1278,15 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
// mp4 would be 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', but Android doesn't like it
$types['mp4'] = '';
$alternatives = media_alternativefiles($src, $extensions);
+ $poster = media_alternativefiles($src, array('jpg', 'png'), true);
+ $posterUrl = '';
+ if (!empty($poster)) {
+ $posterUrl = ml(reset($poster),array('cache'=>$cache),true,'&');
+ }
- // @todo: add poster
- $this->doc .= '<video '.buildAttributes($atts).' controls="controls">'.NL;
+ $this->doc .= '<video '.buildAttributes($atts).' controls="controls"';
+ if ($posterUrl) $this->doc .= ' poster="'.$posterUrl.'"';
+ $this->doc .= '>'.NL;
foreach($alternatives as $ext => $file) {
$url = ml($file,array('cache'=>$cache),true,'&');
$type = $types[$ext];