martignoni / hugo-video

A Hugo theme component to embed videos using HTML video element
GNU General Public License v3.0
105 stars 27 forks source link

Add support for autoplay and loop attributes #1

Closed grrowl closed 4 years ago

grrowl commented 4 years ago

Now I can do this:

{{% video src="future-video" autoplay="true" loop="true" %}}

having any value defined for "autoplay" or "loop" will add the properties to the video element

grrowl commented 4 years ago

Although just realised these are boolean attributes — so this should be an if instead of a when — ~please stand by~

edit: this is done, thanks!

grrowl commented 4 years ago

Added muted too, since I happened to see this on the MDN docs for video:

In some browsers (e.g. Chrome 70.0) autoplay doesn't work if no muted attribute is present.

There might be a better way handle simple boolean attributes in code (with a Map or something) but I'm a little bit new to hugo shortcodes, but happy to take suggestion. Thanks!

martignoni commented 4 years ago

This is not forgotten, but I didn't have the time to integrate it yet :-/

grrowl commented 4 years ago

Great feedback, thanks! Updated the PR