Search code examples
phphtmlimageattachmentprestashop-1.6

Display product attachment in prestashop


In prestashop when I add a picture as an attachment to a product it saves file in download/filename but the problem is that the filename is without extension

eg. b112ddf78daac05a027abd52e67e8d2d6e6dee0a

How to display picture in html (<img src="">) if filename does not have an extension?


Solution

  • I'm assuming you're using the $attachments array to display the image on the product page? Since the extension doesn't matter (the browser looks for the mime type, see more here), you could do the following :

    {foreach from=$attachments item=attachment name=attachments}
      <img src="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">
    {/foreach}