jsmrtn / craftagram

Grab Instagram content through the Instagram Basic Display API
Other
14 stars 8 forks source link

media_type conditional #33

Closed bigskillet closed 3 years ago

bigskillet commented 3 years ago

I'm getting broken images in my feed because they're actually videos. How might I create a conditional so that the <img> tag switches to a <video> tag when applicable? Would you mind providing an example? Thanks!

jsmrtn commented 3 years ago

You want to check if the media type is image or not. media_type Can be IMAGE, VIDEO, or CAROUSEL_ALBUM.

So you should put a check in your loop

{% for item in craftagram.data %}
   {% if item.media_type == "IMAGE %}
       <img src={{item.media_url}} />
   {% elseif item.media_type == "VIDEO" %}
      [..]
  {% else ....
      [..]
  {% endif %}
{% endfor %}