Add a project cover but skip the cover in the gallery ... not working

Hi all,

i read an old thread ( How to add a project cover but skip the cover in the gallery? ) about skipping the Cover Image in a Gallery but i dont get it to work for me. Iam using a Gallery (Flickity Gallery) and my Code looks like this:

<div class="gallery" data-flickity='{ "wrapAround": true }' <?= attr(['data-even' => $gallery->isEven(), 'data-count' => $gallery->count()], ' ') ?>>

	    <?php foreach ($gallery as $image): ?>
	  	<figure>
      	<img 
        src="<?= $image->link()->or($image->url()) ?>"
        sizes="100vw"        
        alt="">    
		</figure>
	   <?php endforeach ?>

Like in the thread i mentioned they found a solution with the not() Parameter so i added to my Code:

<?php foreach ($gallery->not('cover.jpg') as $image): ?>

But its still not working. The Cover Image (cover.jpg) was uploaded as a Image to the Gallery and selected as the Cover Image. The Filestructure is like at the Screenshot.

Can someone Help me pls?

27

This should work:

$gallery = $page->images()->not($page->image('cover.jpg'));

Looks like if you want to pass a string, you have to pass the complete file id.

without the Semicolon ; at the end its working fine :slight_smile:

Thank you very much !