通过元字段 “File reference” 上传文件时,如何在前端主题中显示它?

huangapple go评论52阅读模式
英文:

When uploading a file via metafield "File reference", how can I display it to the front theme?

问题

如下文档所示,可以使用文件引用元字段上传PDF文件。然而,在主题中显示时,我无法使其正常工作。是否有关于此的有效示例?谢谢。

通过元字段 “File reference” 上传文件时,如何在前端主题中显示它?

英文:

As seen in the documentation below, it is possible to upload a PDF file using File referance metafield. However, I cannot get it to work when displaying it to the front end in a theme. Are there any working examples for this? Thank you.

通过元字段 “File reference” 上传文件时,如何在前端主题中显示它?

答案1

得分: 1

在Liquid中,您可以使用file_url过滤器获取URL,并使用iframe显示PDF文档预览:

<iframe src="{{ product.metafields.my_fields.name_of_pdf_field | file_url }}"></iframe>
英文:

In Liquid you can use file_url filter to get the URL and use iframe to display the PDF document preview:

&lt;iframe src=&quot;{{ product.metafields.my_fields.name_of_pdf_field | file_url }}&quot;&gt;&lt;/iframe&gt;

huangapple
  • 本文由 发表于 2023年3月12日 13:05:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75711143.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定