How to change the way Kirbytext adds video embeds?

I am creating a portfolio website for a design company.

They are dropping images and videos in the order they are to appear using kirbytext tags. I am able to position the element that is created by (video: ) kirbytext in the position I want at the size I want, but I don’t know how to add autoplay to it. In another thread I saw something about editing the config to change the way Kirby writes the embed code, but I don’t know which config file this should go into.

Thank you!

You can set the options in the /site/config/config.php which is the only config file there is.

The post linked above looks like it should help me, but I am at a loss on how to implement this.

I want the video source to show up with the following attached:

?autoplay=1&loop=1&muted=1

I have been staring at the above linked post and trying to figure out where to begin. I created a config.php, put the following code to no avail, but I’m pretty sure I’m missing something significant:

<?php


return [
  'kirbytext' => [
    'video' => [
      'class' => 'site__video',
      'height' => false,
      'width' => false,
      'autoplay' => true,
    ]
  ]
];

?>

I even tried going to the source and fiddling with the helpers or the tags file. I was able to get the class to change, but I can’t figure out how to modify the urls.

That looks different from what I posted in the other thread?

I tried it as below, which is exactly what you had posted in the other thread, except changing youtube to vimeo. Is this supposed to go in config.php? Or somewhere else? there’s a bunch of other code in the other thread that it looks like the attached code is supposed to modify, but I don’t know where that is.

'kirbytext' => [
    'video' => [
        'options' => [
            'vimeo' => [
                'autoplay' => true,
                'controls' => 0,
                'modestbranding' => 1,
                'showinfo' => 0
            
        
                ]
        ]
    ]
    
] 

I haven’t been able to get any results out of the config method. However, if anyone finds this in the future, I was able to solve my problem with a few lines of javascript, which are then called alongside any other $(document).ready() stuff.

function vimeo_funtimes() {
	$('iframe').each(function( index ) {
		var vimeosrc = $(this).attr('src') + '?background=1&autoplay=1&loop=1&muted=1';
		$(this).attr('src', vimeosrc);
	});	
}

For me, the above works, the src attribute in the iframe then looks like this:

src="https://player.vimeo.com/video/311644911?autoplay=1&controls=0&modestbranding=1&showinfo=0"

You can also create your own tag that does exactly what you need.

If I wanted to achieve this functionality with a custom Kirbytext tag, how would I do this?

I have tried to follow this guide…
https://getkirby.com/docs/reference/plugins/extensions/kirbytags#how-to-create-your-own-kirbytag

I started by creating:
/site/plugins/tnc/index.php

And then I copied this code straight from the guide, replacing only ‘your-plugin’ with ‘tnc’:

Kirby::plugin('tnc', [
    'tags' => [
        'wikipedia' => [
            'html' => function($tag) {
                return '<a href="http://wikipedia.org">Wikipedia</a>';
            }
        ]
    ]
]);

which resulted in this error:

Unexpected token K in JSON at position 0 😭

Thanks for your time.

Your plugins must follow the name pattern

{your-name-or-alias}/{plugin-name}.

If tnc is your name, then the plugin name is missing, or vice-versa.