File extension extraction

Hello,
I would like to test the file extension of an image.

{% assign img = “/images/my_image.jpg” %}

{% if img.extname == ‘.jpg’ %}

That doesn’t work. What is the correct syntax to extract the extension of a file ?

rgds,

I don’t see the relation between page.path and the string “/images/my_image.jpg” !

That was just an example. The important part are the filters applied at the end split and last. Apply those to your assign and it should work the same provided you don’t have periods in your filenames other than before the extension.

{% assign img = "/images/my_image.jpg" | split: "." | last %}

It works !
Thank you