You are here

socialfeed-instagram-post-carousel-album.html.twig in Social Feed 8

Theme implementation to display the Instagram Carousel.

Available variables:

  • attributes: array of HTML attributes populated by modules, intended to be added to the main container tag of this template.
  • post: The filtered data.
    • raw: The basic response data from getUserMedia().

      • caption: The Media's caption text. Not returnable for Media in albums.
      • id: The Media's ID.
      • media_type: The Media's type. Can be IMAGE, VIDEO, or CAROUSEL_ALBUM.
      • media_url: The Media's URL.
      • permalink: The Media's permanent URL. Will be omitted if the Media contains copyrighted material, or has been

    flagged for a copyright violation.

    • timestamp: The Media's publish date in ISO 8601 format.
    • username: The Media owner's username.
    • children: The list of Media on the Media album. Only available if the `type` is CAROUSEL_ALBUM Media.
      • id: The Media's ID.
      • media_type: The Media's type. Can be IMAGE, VIDEO.
      • media_url: The Media's URL.
      • permalink: The Media's permanent URL. Will be omitted if the Media contains copyrighted material, or has been

    flagged for a copyright violation.

    • timestamp: The Media's publish date in ISO 8601 format.
    • username: The Media owner's username.

File

templates/socialfeed-instagram-post-carousel-album.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme implementation to display the Instagram Carousel.
  5. *
  6. * Available variables:
  7. * - attributes: array of HTML attributes populated by modules, intended to
  8. * be added to the main container tag of this template.
  9. * - post: The filtered data.
  10. * - raw: The basic response data from getUserMedia().
  11. * - caption: The Media's caption text. Not returnable for Media in albums.
  12. * - id: The Media's ID.
  13. * - media_type: The Media's type. Can be IMAGE, VIDEO, or CAROUSEL_ALBUM.
  14. * - media_url: The Media's URL.
  15. * - permalink: The Media's permanent URL. Will be omitted if the Media contains copyrighted material, or has been
  16. flagged for a copyright violation.
  17. * - timestamp: The Media's publish date in ISO 8601 format.
  18. * - username: The Media owner's username.
  19. * - children: The list of Media on the Media album. Only available if the `type` is CAROUSEL_ALBUM Media.
  20. * - id: The Media's ID.
  21. * - media_type: The Media's type. Can be IMAGE, VIDEO.
  22. * - media_url: The Media's URL.
  23. * - permalink: The Media's permanent URL. Will be omitted if the Media contains copyrighted material, or has been
  24. flagged for a copyright violation.
  25. * - timestamp: The Media's publish date in ISO 8601 format.
  26. * - username: The Media owner's username.
  27. *
  28. * @see template_preprocess_block()
  29. *
  30. * @ingroup themeable
  31. */
  32. #}
  33. {% if post.media_url %}
  34. {% set alt = post.raw.caption ? post.raw.caption[:50] ~ (post.raw.caption|length > 50 ? '...') : '' %}
  35. {% if post.children %}
  36. <div class="instagram-carousel">
  37. {% for children in post.children.data %}
  38. {% if post.post_url %}
  39. <a href="{{ children.permalink }}" target="_blank">
  40. <img src="{{ children.media_url }}" alt="{{ children.caption }}"/>
  41. </a>
  42. {% else %}
  43. <img src="{{ children.media_url }}" alt="{{ children.caption }}"/>
  44. {% endif %}
  45. {% endfor %}
  46. </div>
  47. {% elseif post.post_url %}
  48. <a href="{{ post.post_url }}" target="_blank">
  49. <img src="{{ post.media_url }}" alt="{{ alt }}"/>
  50. </a>
  51. {% else %}
  52. <img src="{{ post.media_url }}" alt="{{ alt }}"/>
  53. {% endif %}
  54. {% endif %}