Kirby built-in Vimeo embed automatically cleaning up embed link

Hey there great Kirby community,

We am using a vimeo embed in our site. I’d like to add “?background=1” to the end of the vimeo link string as this allows us to play the vimeo video without the play button, etc. However, when I try to add this to the code it seems to sanitize it from the link and remove it?

I have this piece of code on the site (it’s in a kirby builder section):

<?php $vim = $data->link();
$vim .= '?background=1';
?>
<!-- Vimeo embed -->
<?= vimeo("<?= $vim ?>", '100%', '100%', 'vimeo-embed') ?>

I have also tried without the variables and just concatenating it on the end with ‘.’ but to no avail. Any suggestions?

This is not possible using the video helper. You can, however, use the embed class:

<figure class="video-embed">
  <?=  embed::vimeo($data->link(), ['options' => ['background' => 1]]);?>
</figure>

The attribute array here contains an options array. Everything in the options array is used to build the query string.


To give you a bit more background: internally, the vimeo Kirbytag (which is then used by the vimeo() helper via the kirbytag() helper) uses the vimeo() method from the Embed class.

While the helper and the tag accept a URL, they really only need the video ID, therefore everything but the ID is stripped from the URL to build the src attribute of the iframe.

4 Likes

Thanks very much texnixe, great solution and explanation!