You are here

amazon-image.html.twig in Amazon Product Advertisement API 8.2

Renders a link to Amazon using the product's image.

Available variables:

  • image_src: URL of the image.
  • width: (optional) width of the image.
  • height: (optional) height of the image.
  • item: The full return value from the APA API call.
  • size: One of small|medium|large.
  • url: The URL of the Amazon product page with the associates tag.

File

templates/amazon-image.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Renders a link to Amazon using the product's image.
  5. *
  6. * Available variables:
  7. * - image_src: URL of the image.
  8. * - width: (optional) width of the image.
  9. * - height: (optional) height of the image.
  10. * - item: The full return value from the APA API call.
  11. * - size: One of small|medium|large.
  12. * - url: The URL of the Amazon product page with the associates tag.
  13. */
  14. #}
  15. {% if width is not empty %}
  16. {% set attributes = attributes.setAttribute('width', width) %}
  17. {% endif %}
  18. {% if height is not empty %}
  19. {% set attributes = attributes.setAttribute('height', height) %}
  20. {% endif %}
  21. <a href="{{ url }}"><img{{ attributes.setAttribute('src', image_src) }} /></a>