Identifying posts that have images

On a standard archive page, the post list is formatted based on whether posts have titles or not. On posts with titles {{ if .Title }}, it simply shows the title. Otherwise {{ else }}, it shows a truncated version of the shorter posts.

Using the above method, you can also append a :open_book: (or similar) emoji to easily identify long-form posts.

My question is – is there a way to identify when a post has an image? My intent would be to place a :camera: icon in the archive feed for those. I’ve seen a couple of posts in the help center around doing something similar for the home page, but all seemed to have hit a dead end.

Any help is appreciated!

Yes, you can use the parameters Params.images and The first includes JPEGs and PNGs, while the latter only contains JPEGs, as described here.

One possible solution:

{{ if isset .Params "photos" }}📸{{ end }}

Ah, works like a charm. Thank you!

I like this idea and wonder if we should incorporate it into the default Archive page. I could even see including tiny thumbnails (but maybe not until we break the archive into multiple pages for years, because it can be so long).

I’ve had a couple people ask how I did it, so based on that very small sample size, I think it would be accepted.