Re: PDF in metafields

How can I make a PDF metafield appear in dynamic source?

Liutkut
Tourist
7 0 4

Hey.

I have crated some multi-line text metafields in product page. 

I have a problem adding metafield with PDF file. I've already added product metafield definition, accepted all file types. The metafield is added in admin/product page, where I also uploaded the pdf file. All I need right now is that the metafield shows up in the page as a collabsible tab. When I want to insert dynamic source, all the other text metafieds shows up except for the PDF file. What to do that the metafield with PDF shows up in dynamic source? 

Replies 5 (5)

KetanKumar
Shopify Partner
37618 3670 12162

@Liutkut 

can you please share store ulr and metafiles your code

If helpful then please Like and Accept Solution. Partnership of your ️ Coffee Tips and my code can bring miracles.
Want to modify or custom changes on store Hire Me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing
Liutkut
Tourist
7 0 4

What I forgot to mention that I cannot preview uploaded file at all. 

Liutkut_0-1640857619513.png

 

ThomasBorowski
Shopify Partner
803 71 244

@Liutkut wrote:

What I forgot to mention that I cannot preview uploaded file at all. 

 


The file upload dialog only shows previews for image files.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
KetanKumar
Shopify Partner
37618 3670 12162

@Liutkut 

yes, please upload file manage your PDF and link here

If helpful then please Like and Accept Solution. Partnership of your ️ Coffee Tips and my code can bring miracles.
Want to modify or custom changes on store Hire Me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing

ThomasBorowski
Shopify Partner
803 71 244

I'm assuming you created a File metafield for the PDF, not a multiline text field. Internally, the type of this metafield is file_reference.

 

As documented here, metafields of that type can only be hooked up as a dynamic source for image pickers, which means they only work for image files, not for PDF files. At least that's what's currently supported, the theme editor may be extended in the future so you could create a download link or something similar for a PDF file.

 

So to have a download link show up in a collapsible tab you would have to make some modifications to your theme. What you would need is a block that allows custom Liquid code and then you could add a download link to the product's PDF file in the theme editor by adding this code to the Liquid code field of that block:

<a href="{{ product.metafields.my_fields.pdf_file.value.url }}">Download PDF</a>

This code assumes the metafield for the PDF is in the namespace my_fields and the key is pdf_file.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up