Hi all, I have a simple plugin to help me create a neat row of images on a page. Now that Kirby puts all images in the media folder, the URLs returned by my plugin result in 404s.
I’d really appreciate some help with fixing it to refer to the new media URLs.
This is how I call it:
(galleryblock: image1.jpg, image2.jpg, image3.jpg:three class: classname)
The images are uploaded in the panel as normal, the ‘three’ is to call the right css class and the class bit is for any twiddly decorative classes I want to add.
And this is my code. I was rusty at PHP when I wrote it and now I’m practically crumbling, which is why I need help. How do I make it return the right images? Thank you!
<?php
Kirby::plugin('aegir/galleryblock', [
'tags' => [
'galleryblock' => [
'attr' => [
'galleryblock'
],
'attr' => [
'class'
],
'html' => function($tag) {
$class = $tag->class;
$containers = explode('|', $tag->galleryblock);
$thisloc = $tag->parent()->url();
$html = '<div class="gallery-block ' . $class . '">';
foreach($containers as $container) {
// Remove space after the comma
$container = trim($container);
list($images, $size) = explode(':', $container);
//get the image array
$images = explode(',', $images);
foreach($images as $myimage) {
// Remove space after the comma
$myimage = trim($myimage);
$html .= '<figure class="gallery ' . $size . '"><img src="' . $thisloc . '/' . $myimage . '"></figure>';
}
}
return $html . '</div>';
}
]
]
]);