You can assign media objects to the various entities in Shopware’s Storefront. For example, on the product detail page, this is frequently used to display more information with images. This guide should help you get started with using media and thumbnails in your Storefront plugin.

1. add the code to this location

custom/plugins/PluginName/src/Resources/views/storefront/element/CustomElementName.html.twig

{%  set sliderConfig = element.fieldConfig.elements %}

<div class="cms-custom-image">
        {% set media = searchMedia([sliderConfig.media.value], context.context) %}
            {# @var item \Shopware\Core\Content\Media\MediaEntity #}
                  {% for item in media %}
                          <img src="{{ item.url }}">
                   {% endfor %}   
 </div>

show custom media on storefront template

Avatar photo
Author

Founder and tech lead at Emizentech, Mr. Vivek has over ten years of experience in developing IT infrastructures and solutions. With his profound knowledge in eCommerce technologies like Shopware, Magento, and Shopify, Mr. Vivek has been assisting SMEs to enterprises across the globe by developing and maintaining their eCommerce applications. Technology innovation and trends insight come easy to Vivek with his thorough knowledge in the eCommerce domain. See him talking about ideas, trends, and technology in this blog. To know more about how Team Vivek can assist you in your eCommerce strategy? Connect team Vivek here.

whatsapp