Retrieve URL from a PDF ID set with ACF field

Hi team,
I have a product page set with several ACF fields, where about binaries there are 2 file types:

  • 3 Images for the carroussel
  • 2 PDF for commercial and specs-sheet, downloadable from given buttons.

IDs for images and PDFs are informed at backend like this (in a #Number field type)

image
(PDFs may match, this is not a factor)

Image IDs are working fine and showing the images in the slider container as expected, both back&frontend.

So this is working: {{dc:acf:post_field field=“specs_carrusel_slide2” size=“medium”}}

However, for the PDF I get …/pageURL/6314 instead of …/pageURL/model-x-specs.pdf

Been reading across the forum, docs and ACF stuff, but after some testing I need to speed it up.
Please, what am I missing? Any nice {{dc:hack}}?

Thank you!

Hey Ricard,

Thanks for reaching out!

It is really hard to anticipate your issue without checking the backend settings. That being said, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password
  • Page URL in question

You can find the Secure Note button at the bottom of your posts.

Thank you.

Done, ready for you to play around. Thank you!

Hey Ricard,

I have thoroughly investigated the issue. Having to use the dynamic content like this {{dc:acf:post_field field="specs_carrusel_slide2" type="image" size="medium"}} will display the image URL of the particular number. You cannot use this to return any other file because there isn’t any feature yet. You should be using the URL Field type or the File type for the PDF links.

Best Regards.

Changed to your recommendation for the PDF issue, now works as expected, thank you so much!

However I have re-read your phrase about the images in the carrousel and now I see what you really mean: by using this shortcode I am getting the file itself, so most probably at max size:

{{dc:acf:post_field field="specs_carrusel_slide1" type="image" size="medium"}}

In fact I am inspecting the slides and indeed the images are always at 1536px width, so it does ignore the size attribute.

I humbly think this trick has sense for being effective in next revisions, isn’t it?

Thanks for your kind support

Hey Ricard,

You are most welcome. The size attribute works best with featured images. For ACF dynamic content it may not work because ACF fields have return settings and the dynamic content only returns what is served by the ACF field.

Cheers.

Thanks for enlighting me! This little change does the job perfectly:

Turn ACF field to Text type instead of Number, then just add manually the size as “:size”

image

This is the net output of the trick, updated field vs number type field:

image

The plumbing is simply {{dc:acf:post_field field="field-name"}}
Since I have 2 sections split for bigger and smaller viewports, I get the desired output for SEO and performance.

Thanks for your suport!

You are most welcome, Ricard.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.