From aaa3f82843b687ecb562cc55c60776ae69ee8539 Mon Sep 17 00:00:00 2001 From: Philip Frenette Cloutier Date: Fri, 21 Apr 2017 11:31:37 -0400 Subject: [PATCH] Add more controls over HTML5 video attributes (autoplay, poster, loop controls) --- .../Grav/Common/Page/Medium/VideoMedium.php | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/system/src/Grav/Common/Page/Medium/VideoMedium.php b/system/src/Grav/Common/Page/Medium/VideoMedium.php index 51690da0f9..31e426549f 100644 --- a/system/src/Grav/Common/Page/Medium/VideoMedium.php +++ b/system/src/Grav/Common/Page/Medium/VideoMedium.php @@ -30,6 +30,75 @@ protected function sourceParsedownElement(array $attributes, $reset = true) ]; } + /** + * Allows to set or remove the HTML5 default controls + * + * @param bool $display + * @return $this + */ + public function controls($display = true) + { + if($display) + { + $this->attributes['controls'] = true; + } + else + { + unset($this->attributes['controls']); + } + return $this; + } + + /** + * Allows to set the video's poster image + * + * @param $urlImage + * @return $this + */ + public function poster($urlImage) + { + $this->attributes['poster'] = $urlImage; + return $this; + } + + /** + * Allows to set the loop attribute + * + * @param bool $status + * @return $this + */ + public function loop($status = false) + { + if($status) + { + $this->attributes['loop'] = true; + } + else + { + unset($this->attributes['loop']); + } + return $this; + } + + /** + * Allows to set the autoplay attribute + * + * @param bool $status + * @return $this + */ + public function autoplay($status = false) + { + if($status) + { + $this->attributes['autoplay'] = true; + } + else + { + unset($this->attributes['autoplay']); + } + return $this; + } + /** * Reset medium. *