Adding custom attribute to some webp images

Hi,

I’m trying to get the webp plugin from hash and salt by @jimbobrjames to work on my website and for some images I want to use a lightbox for which I’m using Fancybox. This requires me to add a custom attribute data-fancybox to the element.

If I change the webp.php snippet, every image gets a lightbox so I tried copying the snipped and rename it to wepb-lightbox.php but if I try refferencing that in my template like <?php snippet('webp-lightbox', ['sizes' => [1920, 1140, 640, 320], 'src' => 'yourimage.webp', 'type' => 'png', 'class' => null, 'width' => 800, 'height' => 600]) ?> the images don’t render.

Is there something I’m missing here or how can I make this work?

What are you passing for src? This needs to be a file object.

As image I pass in a variable $image. Everything works with the regular ‘webp’ snippet but stops working when I try to use a different snippet

Where did you put the new snippet? Is it used at all?

I added the snippet in the plugins/kirby3-webp/snippets folder where the other webp snippet is as well

Well, you have to put the snippet into your /site/snippets folder (never touch a plugin), otherwise Kirby will not know anything about it.

Thanks that solved it:)