Dynamic sources - File reference type not display / unable to connect.

Dynamic sources - File reference type not display / unable to connect.

Deanosaurus
Tourist
6 0 2

I am unable to connect Dynamic sources to file metafields. Is there a workoaround to this? I only seem to be able connect Rich/Single line text. 

problem1.pngproblem 2.pngError.png

This is the error I get once i code in the file reference metafield name:

 {{ product.metafields.custom.product_installation_pdf }}

 

Any help?

Replies 2 (2)

MaverickStudio
Shopify Partner
101 32 34

Hey @Deanosaurus ,

You can't use a file directly as a metafield as of now. Files are only available in image pickers.

Here is the custom liquid to add pdf via metafields.

 

 

{% if product.metafields.custom.product_installation_pdf != blank %}
  <a
    href="{{ product.metafields.custom.product_installation_pdf | file_url }}"
    style="text-decoration: underline;"
    target="_blank"
  >
    Download Manual
  </a>
{% endif %}

 


If you want the file to be downloaded instead of opening in a new tab, use the following.

{% if product.metafields.custom.product_installation_pdf != blank %}
  <a
    href="{{ product.metafields.custom.product_installation_pdf | file_url }}"
    style="text-decoration: underline;"
    target="_blank"
    download
  >
    Download Manual
  </a>
{% endif %}


 Screenshot 2024-07-25 191835.png

♥ If you found my solution helpful, please consider giving it a Like and marking it as the ✔ Accepted Solution


Try our WhatsApp Chat Button Widget with multipe agents.Supachat: WhatsApp Chat Button


A Product of Maverick Studio

Deanosaurus
Tourist
6 0 2

That's not entirely true - My shop has metafield with file, and it displays on my products as PDF. What I'm trying to replicate is the same / or have liquid code in those tabs.

 

As for the custom liquid code you just pasted, I got a better one, which basically makes the field empty unless you populate the metafield with the file.

 


{% unless product.metafields.custom.product_installation_pdf.value.url == null %}
<a target="_blank" href="{{ product.metafields.custom.product_installation_pdf
.value.url }}">Download Product Installation PDF</a>
{% endunless %}

 

 

image_2024-07-25_102404816.png