Embedding vimeo content on through Kirby

I’m new to kirby and web development in general. I’m making a single page portfolio site with projects that consist of images and occasionally an embedded vimeo video. I’ve managed to install the oembed plugin but I’m have a few problems.

  1. For projects that don’t have a vimeo video the phrase ‘No medium found for URL’ is displayed. How can I get rid of this?

  2. I can’t get the vimeos to autoplay despite setting these in both per embed options and global options

  3. It would also be preferable if the oembed thumb was not displayed. How can I set this?

Apologies for my inexperience.
Maybe oembed is not appropriate for what i’m trying to achieve. Is there another plugin or solution that would allow vimeo content to be added through the panel but use the autoplay features and embed options inherent in Vimeo?

Thanks for any help.

Could you post your code pls and how do you enter video urls in the panel?

Which but of the code specifically? I use just a normal vimeo link and it works. The problem is that for projects that aren’t supposed to have vimeo links, I don’t want anything to appear on the screen, instead the message ‘No medium found for URL’ displays.

That why I wanted your template code, you could wrap it in an if statement that checks if the field is empty or not and then either executes the code or not.

<?php
if($page->field()->isNotEmpty()): ?>
// do something
<?php endif ?>

I see. My template code is this:

<?= $project->featured_video()->oembed([
    'lazyvideo' => true,
     'autoload' => true,
 ]); ?>

You should use the code texnixe posted above to verify if the field exists:

<?php
if($project->featured_video()->isNotEmpty()):
 echo $project->featured_video()->oembed([
   'lazyvideo' => true,
   'autoload' => true,
 ]);
endif; ?>

Edited code. Thx @texnixe

There is also a thumb option, maybe you can set this to an empty string (not tested):

<?php
if($project->featured_video()->isNotEmpty()):
 echo $project->featured_video()->oembed([
   'lazyvideo' => true,
   'autoload' => true,
   'thumb' => '',
 ]);
endif ?>

Or you can set this to a custom thumbnail.

Edit: As regards autoplay, have you tested this in multiple browsers?

Thanks for the suggestions, unfortunately this removes the vimeos as well for me

There is an echo statement missing:

<?php
if($project->featured_video()->isNotEmpty()):
 echo $project->featured_video()->oembed([
   'lazyvideo' => true,
   'autoload' => true,
   'thumb' => '',
 ]);
endif ?>
```
1 Like

Perfect! Thank you for your help. I changed the thumbnails opacity to 0, this will do for now.

I’ve tested the in different browsers and autoplay still doesn’t work. Do you think there is way to use the autoplay embed properties inherent in Vimeo?

I could not get the autoplay feature to run either and I don’t know how it is implemented in Vimeo. Have you tried the vimeo kirbytag yet as an alternative?

Edit: No, the kirbytag does not have an autoplay option, I’m afraid.

I saw this post of yours. I’m trying to use this solution instead.

How could I use this to embed an iframe like this:

<iframe src="https://player.vimeo.com/video/176585406?autoplay=1&loop=1&title=0&byline=0&portrait=0" width="1000" height="563" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> 

which has the autoplay inherent in the code.

In the blueprint i’ve put the code:

vimeolinks:
label: Vimeo Links
type: structure
entry: >
  {{vimeovid}}<br />
fields:
  vimeovid:
    label: Vimeo
    type: text

and the following php:

 <?php foreach($project->vimeolinks()->yaml() as $vimeovid): ?>
     <?php echo vimeo($vimeovid['vimeoid']) ?>
  <?php endforeach ?>

Is there anyway of this working?

Thanks again for the help

If that iframe works for all vimeo videos, you could just replace the vimeo ID in the iframe source:

<?php foreach($project->vimeolinks()->toStructure() as $vimeovid): ?>
<?php $videoID = $vimeovid->vimeoid(); ?>
  <iframe src="https://player.vimeo.com/video/<?= $videoID ?>?autoplay=1&loop=1&title=0&byline=0&portrait=0" width="1000" height="563" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<?php endforeach ?>

apologies I didn’t make that very clear, this is the iframe I want to embed by pasting it in the text field through the panel

Then you have to modify your code a little bit:

<?php foreach($project->vimeolinks()->yaml() as $vimeovid): ?>
     <?php echo $vimeovid['vimeoid'] ?>
<?php endforeach ?>
```

This will then just embed the iframe though. You can't use that together with the vimeo helper, I guess.
1 Like

Embedding the iframe this way would be a better solution. But it still doesn’t seem to be working

What is the problem exactly with that approach?

It’s working now, a problem with the syntax. Thank you very much for your help texnixe, you’re a legend.

Sorry, I completely missed this. Will look into why the autoplay option does not work.

Realized that with 2.0 I missed updating that option in the docs. I’m sorry for that. It must be autoplay:

<?php
if($project->featured_video()->isNotEmpty()):
 echo $project->featured_video()->oembed(['autoplay'  => true]);
endif ?>

I will also add more provider specific url parameter support (like loop etc.) to an upcoming version.

1 Like