【问题标题】:Display product attachment in prestashop在 prestashop 中显示产品附件
【发布时间】:2018-05-25 20:25:27
【问题描述】:

在 prestashop 中,当我将图片作为附件添加到产品时,它会将文件保存在 download/filename 中,但问题是文件名没有扩展名

例如。 b112ddf78daac05a027abd52e67e8d2d6e6dee0a

如果文件名没有扩展名,如何在 html (<img src="">) 中显示图片?

【问题讨论】:

    标签: php html image attachment prestashop-1.6


    【解决方案1】:

    我假设您正在使用$attachments 数组在产品页面上显示图像?由于扩展名无关紧要(浏览器会查找 mime 类型,请参阅更多 here),您可以执行以下操作:

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

    【讨论】:

      【解决方案2】:

      无需扩展。只需将变量传递给src 就可以了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-10
        相关资源
        最近更新 更多