3

I have created a custom module email template, but I am unable to load the images in custom.html file for email templates.

5

Create a static block insert images in that block and call it in respected custom.html files

{{block class="Magento\Cms\Block\Block" area='frontend' block_id="my_block"}}

2
  • Good to know you solved. Nov 28 '17 at 5:44
  • How to include this block to my custom module this block create automatically when my module loads Nov 28 '17 at 6:10
2

The easiest way is to include the block. For example:

vendor/magento/module-sales/view/frontend/email/shipment_new.html

{{block class='Magento\\Framework\\View\\Element\\Template' area='frontend' template='Magento_Sales::email/shipment/track.phtml' shipment=$shipment order=$order}}

Or, We can pass the data to the email template. For example:

vendor/magento/module-email/view/frontend/email/header.html

                     <img
                            {{if logo_width}}
                                width="{{var logo_width}}"
                            {{else}}
                                width="180"
                            {{/if}}

                            {{if logo_height}}
                                height="{{var logo_height}}"
                            {{else}}
                                height="52"
                            {{/if}}

                            src="{{var logo_url}}"
                            alt="{{var logo_alt}}"
                            border="0"
                        />
10
  • thanks for the reply where I have to place the images and call it in custom.html file Nov 27 '17 at 18:17
  • Check my code and let me know. Nov 28 '17 at 0:32
  • thanks khoa iam installed one custom module for email load at admin emails but unable call the images infooter section from pub media Nov 28 '17 at 3:23
  • you given a logo urls Nov 28 '17 at 3:24
  • I only give you a sample. You need to build your own. I think it's better if you use the first solution. Nov 28 '17 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.