# EMail Templates: Wie können Thumbnails in den EMail Templates integriert werden?

**URL:** <https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625>\
**Category:** Themes & Design\
**Created:** [18. Dezember 2020 um 09:52 UTC](https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625 "2020-12-18T09:52:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagodi](https://avatars.discourse-cdn.com/v4/letter/n/f04885/32.png) [@nagodi](https://forum.shopware.com/u/nagodi)\
**Post date:** [18. Dezember 2020 um 09:52 UTC](https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625/1 "2020-12-18T09:52:03Z")

</div>

Hallo!

In unseren EMail Templates der Bestellbestätigung und Status Updates sollen die Thumbnails der lineItems angezeigt werden. In den lineItems ist die mediaId in der Variable ‘coverId’ hinterlegt.

Bisherige Versuche über **searchMedia()** function

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {# fetch media as batch - optimized for performance #}  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% set mediaCollection = searchMedia([sportsMediaId], context.context) %}

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{# extract single media object #}  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{% set sportsMedia = mediaCollection.get(sportsMediaId) %}

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{{ dump (sportsMedia) }}

=\> official docu:[&nbsp;https://docs.shopware.com/en/shopware-platform-dev-en/how-to/custom-fields-media-type](https://docs.shopware.com/en/shopware-platform-dev-en/how-to/custom-fields-media-type)  
=\> discussion:&nbsp;[https://forum.shopware.com/discussion/65543/customfields-media-ausgabe](https://forum.shopware.com/discussion/65543/customfields-media-ausgabe)

Das Problem der searchMedia() function scheint, dass in den Mail Templates **kein context** vorhanden ist; außerdem erhalte ich keine Ausgabe bei **{{ dump() }}** (environment ist aber auf dev)

Habt ihr Ideen?  
Wie holt ihr euch die Bilder / Links?

Danke!

---

<div class="post-metadata">

**Author:** ![kanuma](https://avatars.discourse-cdn.com/v4/letter/k/ce7236/32.png) [@kanuma](https://forum.shopware.com/u/kanuma)\
**Post date:** [20. Januar 2021 um 12:17 UTC](https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625/2 "2021-01-20T12:17:59Z")

</div>

PUSH

---

<div class="post-metadata">

**Author:** ![datema-nt](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@datema-nt](https://forum.shopware.com/u/datema-nt)\
**Post date:** [25. März 2021 um 19:37 UTC](https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625/3 "2021-03-25T19:37:44Z")

</div>

Wir generieren Dokumente (wie Lieferscheine + Rechnungen) und hatten auch Gebrauch anhand von MediaIDs die MediaObjekte via searchMedia() zu beziehen.

Gleich wie bei den email-Templates fehlt uns auch der **context**.

Wir haben aber herausgefunden, dass das Context aber im Templatekopf schon hinzugefügt wurde.  
{# @var context \Shopware\Core\Framework\Context #}

Daher konnten wir darauf zugreifen mit  
{{ searchMedia([mediaId], context).first()|sw\_encode\_media\_url }}

Jetzt kommt mein dämlicher Vorschlag:  
Probiert es mal mit  
{% set mediaCollection = searchMedia([sportsMediaId], context) %}  
und macht aus **context.context** einfach **context**

---

<div class="post-metadata">

**Author:** ![FloC3](https://avatars.discourse-cdn.com/v4/letter/f/838e76/32.png) [@FloC3](https://forum.shopware.com/u/FloC3)\
**Post date:** [19. April 2021 um 15:07 UTC](https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625/4 "2021-04-19T15:07:53Z")

</div>

In Bestellbestätigung oder Dokumenten:

```
{# @var context \Shopware\Core\Framework\Context #}
<img src="{{ searchMedia([lineItem.coverId], context).first()|sw_encode_media_url }}" width="100" />
```

---

<div class="post-metadata">

**Author:** ![SmartStylez](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@SmartStylez](https://forum.shopware.com/u/SmartStylez)\
**Post date:** [2. Mai 2021 um 16:02 UTC](https://forum.shopware.com/t/email-templates-wie-konnen-thumbnails-in-den-email-templates-integriert-werden/71625/5 "2021-05-02T16:02:12Z")

</div>

Könntest du hierzu bitte mal ein Beispiel posten?
