how to detect screen size or mobile/desktop using twig

Viewed 10562

I am currently using twig as my templating engine and I wanted to load different url of an image when the site is loaded using mobile vs desktop. Is there an easy way to do this?

So I wanted to do something like this:

{% if (mobile) %}
   <img src="{{ picture.getLowresimageurl() }}"/>
{% else %}
   <img src="{{ picture.getMedresimageurl() }}"/>
{% endif %}

is there a way to do this?

1 Answers
Related