# Display the first image of slideshow

**URL:** <https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275>\
**Category:** Questions\
**Tags:** v2\
**Created:** [September 19, 2018, 1:14pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275 "2018-09-19T13:14:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![QuentinJuhel](https://avatars.discourse-cdn.com/v4/letter/q/a587f6/32.png) [@QuentinJuhel](https://forum.getkirby.com/u/QuentinJuhel)\
**Post date:** [September 19, 2018, 1:14pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275/1 "2018-09-19T13:14:08Z")

</div>

Hi !

I’m using this plugin : [[GitHub - medienbaecker/kirby-images](https://github.com/medienbaecker/kirby-images)]([http://kirby](http://kirby) images) to create a gallery of images.  
I want to display only the first image of this slideshow on Homepage. Actually I display all the image of the gallery with this line of code :

```
    <?php foreach($pages-> find('works')->children() as $preview): ?>
      <?php foreach($preview->slideshow()->yaml() as $image): ?>
        <?php if($image = $preview->image($image)): ?>
          <?= $image->html(); ?>
        <?php endif ?>
      <?php endforeach ?>
   <?php endforeach ?>

```

I had try to use limit(), but it doesn’t work…  
I’ll continue to search on my side with a JS fuction, but I’m not sure is quite a good solution.  
If you have any suggestion, I’ll be happy to read you.

Thanks a lot

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 19, 2018, 1:26pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275/2 "2018-09-19T13:26:51Z")

</div>

```auto
if($image = $preview->image($preview->slideshow()->yaml()[0]) {
  // do stuff
}

```

(without the foreach loop, of. course)

---

<div class="post-metadata">

**Author:** ![QuentinJuhel](https://avatars.discourse-cdn.com/v4/letter/q/a587f6/32.png) [@QuentinJuhel](https://forum.getkirby.com/u/QuentinJuhel)\
**Post date:** [September 19, 2018, 2:25pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275/3 "2018-09-19T14:25:53Z")

</div>

I did that :

```
<?php foreach($pages-> find('works')->children() as $preview): ?>
    <?php if($image = $preview->image($preview->slideshow()->yaml()[0]) { echo $image->html(); }?>
<?php endforeach ?>

```

But I still have a Parse error.

I’m not yet good in php…

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 19, 2018, 2:40pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275/4 "2018-09-19T14:40:50Z")

</div>

Sorry, there’s closing parenthesis missing

```auto
<?php if($image = $preview->image($preview->slideshow()->yaml()[0])) { echo $image->html(); }?>

```

---

<div class="post-metadata">

**Author:** ![QuentinJuhel](https://avatars.discourse-cdn.com/v4/letter/q/a587f6/32.png) [@QuentinJuhel](https://forum.getkirby.com/u/QuentinJuhel)\
**Post date:** [September 19, 2018, 2:48pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275/5 "2018-09-19T14:48:20Z")

</div>

Thanks, it was so simple.  
Hard to see after a sprint work

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:26pm UTC](https://forum.getkirby.com/t/display-the-first-image-of-slideshow/11275/6 "2025-02-06T17:26:09Z")

</div>

Archived on February 6, 2025, 5:26pm UTC


