# Control html video tag from panel

**URL:** <https://forum.getkirby.com/t/control-html-video-tag-from-panel/5691>\
**Category:** Questions\
**Tags:** v2\
**Created:** [November 6, 2016, 2:35pm UTC](https://forum.getkirby.com/t/control-html-video-tag-from-panel/5691 "2016-11-06T14:35:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carstenh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/carstenh/32/6424_2.png) [@carstenh](https://forum.getkirby.com/u/carstenh)\
**Post date:** [November 6, 2016, 2:35pm UTC](https://forum.getkirby.com/t/control-html-video-tag-from-panel/5691/1 "2016-11-06T14:35:50Z")

</div>

Hi,

I am trying to set the html5 `<video>` tag options from the panel and I am wondering what the best way is to achieve this.

In the blueprint I added

```
  videooptions: 
    label: Video options
    type: checkboxes
    columns: 4
    options: 
      showcontrols: Show Controls
      autoplay: Autoplay Video
      loop: Loop video
      mute: Mute Audio

```

In the php file I created the according variables and the following html / php which works.

```
<video id="vid" <?php echo $controls, $play, $loop, $mute, $poster ?>
source src="<?=$video->url()?>" type="video/mp4" />
</video>

```

I am having problems interfacing the variables with the settings / checkboxes from the panel since they return 0 or 1 or bool() which is true or false if I understood it correctly?

So I tried something like

if $page-\>autoplay() == 1  
$play = "autoplay ";

which doesn´t work for some reason. And I guess there is a much smarter way.  
May be someone can point me into the right direction.

Many thanks in advance.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 6, 2016, 5:16pm UTC](https://forum.getkirby.com/t/control-html-video-tag-from-panel/5691/2 "2016-11-06T17:16:15Z")

</div>

The checkboxes field adds a comma separated list of options in your content file, which then looks something like this:

```nohighlight
Videooptions: showcontrols, loop

```

depending on the selected options.

So you can use `in_array` to check if an option was selected:

```auto
<?php
$videoOptions = $page->videooptions()->split(',');
in_array('autoplay', $videoOptions)? $play = 'autoplay': $play = '';
?>

```

---

<div class="post-metadata">

**Author:** ![carstenh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/carstenh/32/6424_2.png) [@carstenh](https://forum.getkirby.com/u/carstenh)\
**Post date:** [November 6, 2016, 10:27pm UTC](https://forum.getkirby.com/t/control-html-video-tag-from-panel/5691/3 "2016-11-06T22:27:23Z")

</div>

Works perfectly now, many thanks!

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:54pm UTC](https://forum.getkirby.com/t/control-html-video-tag-from-panel/5691/4 "2025-02-06T16:54:48Z")

</div>


