Two files sections gallery with different class

Hi everyone,

i have two galeries in my blueprint for a project page, one for landscape images and the other for portrait images (not in all projetcs). They are both in a grid container with two colums, Iā€™d like to change the class for portrait image (landscape span to the end and one portrait images by column.) It works with two foreach loops but iā€™m sure there is a simple way to do this :slight_smile:

Thanks,
Thibault

  - width: 1/2
    sections:
      gallery:
        headline: Gallerie paysage
        type: files
        template: image
        layout: cards
        alt:
          label: Alt Text
          type: text
        image:
          cover: true
          ratio: 3/2
      portrait:
        headline: Gallerie portrait
        type: files
        template: portrait
        layout: cards
        alt:
          label: Alt Text
          type: text
        image:
          cover: true
          ratio: 1/2
<section class="gallery-grid">        
            <?php foreach ($page->images()->filterBy('template', 'image')->sortBy('sort', 'asc') as $image): ?>
                <div class="gallery-items">  
                <figure>
                    <img
                        src="<?= $image->url() ?>"
                        srcset="<?= $image->srcset() ?>"                       
                    />              
                </figure>
                </div>
              
            <?php endforeach ?> 
            </section>
<section class="gallery-grid">        
            <?php foreach ($page->images()->filterBy('template', 'portrait')->sortBy('sort', 'asc') as $image): ?>
                <div class="gallery-items">  
                <figure>
                    <img
                        src="<?= $image->url() ?>"
                        srcset="<?= $image->srcset() ?>"                       
                    />              
                </figure>
                </div>
              
            <?php endforeach ?> 
            </section>                      

Hey, @Thibaultm Welcome to the forum.

Not quite sure that I understand your question. If I get it correctly, you want to do this in one loop but add a class somewhere when the image is in landscape mode?

Then you can check the image template:

if ($image->template() === 'image') {
  //do stuff
}

Thank you !

Yes, this is what i want to do, thanks a lot!