I’m trying to exclude the og:image from a gallery and tired to use the not() command. This seemed to work in Kirby 2.
It not work for me in Kirby 3:
<?php foreach($page->images()->not('cardcover.jpg')->sortBy('sort') as $image): ?>
Is there a new or better way to do this?
The method seems to expect a file object:
$page->images()->not($page->image('cardcover.jpg'))
Tanks for your fast response, this also does not work for me.
I tired filtering with an if-else function, but that does not work either.
<?php elseif($image->filename() != 'cardcover.jpg'): ?>
I’ll have to look into other reasons why the filename might not be recognised.
Hm, the code works for me in a Starterkit.
What is your Kirby version?
Is the filename correct?
That’s why I’m puzzled.
I’m running 3.1.4 and started from scratch.
<img src=".../media/pages/custom-type/-1341504614-1561366229/cardcover.jpg" alt="">
As you can see above, the filename is correct but still results in the page.
I’m able to exclude Animated-Gifs form being scaled,
<?php if($image->extension() != 'gif'): ?>
but filtering for the filename does not work.
Is caching enabled? Have you cleared the browser cache as well?
I just deleted all caches and the code you provided above does work now.
Sorry about that, I was not aware that php functions can be stuck in cache aswel.