# Filter images by suffix

**URL:** <https://forum.getkirby.com/t/filter-images-by-suffix/1551>\
**Category:** Questions\
**Tags:** v2\
**Created:** [July 7, 2015, 5:53pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551 "2015-07-07T17:53:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [July 7, 2015, 5:53pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/1 "2015-07-07T17:53:20Z")

</div>

Hi,  
how can I filter images through an suffix like \_thumb?  
I tried `foreach($page->images()->not('_thumb.jpg') as $image):` for displaying only the fullsize images.  
But it shows all images also the thumbs.

Cheers

---

<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:** [July 7, 2015, 5:58pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/2 "2015-07-07T17:58:40Z")

</div>

[http://forum.getkirby.com/t/filter-to-exclude-files-that-contain-specific-string-in-their-name/573/4?u=texnixe](http://forum.getkirby.com/t/filter-to-exclude-files-that-contain-specific-string-in-their-name/573/4?u=texnixe)

---

<div class="post-metadata">

**Author:** ![AugustMiller](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/augustmiller/32/160_2.png) [@AugustMiller](https://forum.getkirby.com/u/AugustMiller)\
**Post date:** [July 7, 2015, 6:00pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/3 "2015-07-07T18:00:14Z")

</div>

Given an array of files, like `$page->images()`, you can do something like:

```php
$images = $page->images();
$without_thumbnails = $images->filter(function($image) {
  # Note that the !== or === operators are required for
  # matching, here, because 0 and false mean different
  # things as return values from strpos:
  return strpos($image->filename(), '_thumb') !== false;
});

```

Mind you, there is a [built-in thumbnail generation method](http://getkirby.com/docs/cheatsheet/helpers/thumb)!

@texnixe, via Bastian— nailed it! Good idea to use static `str` class methods. Much easier to read than PHP’s myriad string functions. 😄

---

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [July 7, 2015, 6:14pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/4 "2015-07-07T18:14:45Z")

</div>

Hi,  
thankyou for you help!  
But so much crazy filter functions. I can remember that in Kirby 1 it was so simple with  
-\>not().  
In the archiv forum I had an thread about the same problem, but i have to see that the search function was removed. This is not so pretty!  
Yes of course I know the thumbnailfunction but i don’t want to use it because I have different cropped images.

Cheers

---

<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:** [July 7, 2015, 7:22pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/5 "2015-07-07T19:22:56Z")

</div>

As far as I know, not() only works with specific filenames or an array of file names, not with a wildcard.

Yeah, the search function is missing from the old forum, that’s why I downloaded the stuff and use local search;) works much better (or use google search)

---

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [July 8, 2015, 4:37am UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/6 "2015-07-08T04:37:49Z")

</div>

> [@texnixe](#):
>
> As far as I know, not() only works with specific filenames or an array of file names, not with a wildcard.

Ah okay good to know.

> [@texnixe](#):
>
> Yeah, the search function is missing from the old forum, that’s why I downloaded the stuff and use local search;) works much better (or use google search)

That sounds like a good idea 🙂

---

<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:17pm UTC](https://forum.getkirby.com/t/filter-images-by-suffix/1551/7 "2025-02-06T17:17:06Z")

</div>

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


