Hi People of kirbyland,
I got a zip file and an image, Same Name with appended ‘.jpg’.
Now, when looping zip files as $zip, i want to get the Image like this:
$page->image(basename($zip->root()) . '.jpg); but this returns NULL.
What could be wrong about it?
The root()
doesn’t make much sense here, you want the filename without the extension, trying to find the correct method … used to be name()
in Kirby 2, but Kirby 3 I have to check.
name()
still exists, so:
$page->image($zip->name() . '.jpg')
basename()
still returns the extension of the zip file (or is that what you want?)
I wanted that. But from what you wrote, everything should work (given that I want to pass ‘somefile.zip.jpg’ to $page->image())
I’m puzzled…
There is a closing quote missing in your code above… don’t know if that is really in your code or just from copying here.
Should be:
$page->image(basename($zip->root()) . '.jpg');
I counted 3opening, 3closing. I checked my actual code, its just like you posted it…
Not parentheses, I meant the closing quote after .jpg
that is missing in your code snippet in the first post. But if it was missing, your code should throw an error…
I have no idea why you can’t fetch the file unless it is missing…
Riiiight, the missing single quote, yeah, that’s not it… I cant get my head around why its not working…
Does it work if you use a hardcoded filename?
$page->image('somefile.zip.jpg');