Skip to content

Commit

Permalink
Add more controls over HTML5 video attributes (autoplay, poster, loop…
Browse files Browse the repository at this point in the history
… controls)
  • Loading branch information
pfcloutier-druide committed Apr 21, 2017
1 parent 13b3b98 commit aaa3f82
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions system/src/Grav/Common/Page/Medium/VideoMedium.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit aaa3f82

Please sign in to comment.