From 2a2a2ba2f6092b0b68a7de0ccc798062682487f4 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Fri, 2 Aug 2013 21:35:13 +0100 Subject: added basic suport for embedding (html5) videos --- conf/mime.conf | 3 ++ inc/parser/xhtml.php | 66 +++++++++++++++++++++++++++++++++++++++--- lib/images/fileicons/mp4.png | Bin 0 -> 740 bytes lib/images/fileicons/ogv.png | Bin 0 -> 740 bytes lib/images/fileicons/webm.png | Bin 0 -> 740 bytes 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 lib/images/fileicons/mp4.png create mode 100644 lib/images/fileicons/ogv.png create mode 100644 lib/images/fileicons/webm.png diff --git a/conf/mime.conf b/conf/mime.conf index 381b93f86..2a50fab10 100644 --- a/conf/mime.conf +++ b/conf/mime.conf @@ -13,6 +13,9 @@ swf application/x-shockwave-flash mp3 audio/mpeg ogg audio/ogg wav audio/wav +webm video/webm +ogv video/ogg +mp4 video/mp4 tgz !application/octet-stream tar !application/x-gtar diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 84a999e56..747f0e8a0 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -795,8 +795,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { list($ext,$mime,$dl) = mimetype($src,false); if(substr($mime,0,5) == 'image' && $render){ $link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct')); - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -831,8 +831,8 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if(substr($mime,0,5) == 'image' && $render){ // link only jpeg images // if ($ext != 'jpg' && $ext != 'jpeg') $noLink = true; - }elseif($mime == 'application/x-shockwave-flash' && $render){ - // don't link flash movies + }elseif(($mime == 'application/x-shockwave-flash' || substr($mime,0,5) == 'video') && $render){ + // don't link movies $noLink = true; }else{ // add file icons @@ -1093,6 +1093,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $ret .= ' />'; + }elseif(substr($mime,0,5) == 'video'){ + + // first get the $title + if (!is_null($title)) { + $title = $this->_xmlEntities($title); + } + if (!$title) { + // just show the sourcename + $title = $this->_xmlEntities(utf8_basename(noNS($src))); + } + if (!$render) { + // if the video is not supposed to be rendered + // return the title of the video + return $title; + } + + $att = array(); + $att['class'] = "media$align"; + + //add video(s) + $ret .= $this->_video($src, $title, $mime, $width, $height, $att); + }elseif($mime == 'application/x-shockwave-flash'){ if (!$render) { // if the flash is not supposed to be rendered @@ -1226,6 +1248,42 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } + /** + * Embed video(s) in HTML + * + * @author Anika Henke + * + * @param string $src - ID of video to embed + * @param string $title - title of the video + * @param string $mime - mimetype of the video + * @param int $width - width of the video in pixels + * @param int $height - height of the video in pixels + * @param array $atts - additional attributes for the