Hi
I am trying to get the display pdf thumbnail code to work as per this post. This was oroiginally written by Noman
https://toolset.com/forums/topic/how-to-display-thumbnails-of-of-pdfs-uploaded-to-the-types-document-field/
Below is a screenshot of my content template - the post pody for reference just show the url of the document, plus the urls of the thumbnails I see generated on the server.
the grey box below show the output from the 4 following shortcodes
[getpublicationpdfimg]
[getpublicationpdfimg size="large"]
[getpublicationpdfimg size="medium"]
[getpublicationpdfimg size="small"]
I slightly amended the str_relace() to the below which is more in line with the url generated for the thumbnail
$image_url = str_replace(".pdf", "-pdf.jpg", types_render_field( "key-document-eng")); // publication_document = your field name
This is the only change I have done to the code
See screenshot attached hidden link (it is password protected)
I am trying to display a thumbnail which links to the actual file. The php code seems to generate an https://toolset.com/forums/topic/displaying-preview-images-of-uploaded-pdf/
Thanks
Hi,
Thanks for the details,
Q1) So I am trying to tweak the php to achive just a thumbnail which links to the url.
You can change the PHP codes from:
$image_url = str_replace(".pdf", "-pdf.jpg", types_render_field( "key-document-eng")); // publication_document = your field name
To:
$image_url = str_replace(".pdf", "-pdf.jpg", types_render_field( "key-document-eng", array('output'=> 'raw'))); // publication_document = your field name
More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#file
output:
'raw' | 'normal'(default)
Q2) Secondly I noticed on screenshot the shortcodes for different sizes output the same html
I suggest you modify that custom shortcode, output only the image URL, then setup the HTML codes as what you want, for example:
Change this line from:
return '<img src='.$image_src.' class="pubdoc-pdf-image">';
To:
Then setup your HTML codes manually like this:
<a href="{!{types field='key-document-eng' output='raw'}!}{!{/types}!}"><img src="{!{getpublicationpdfimg}!}"></a>
Hi
Sorry for the delay and thanks for the response
This seems to work fine.
Something I forgot to ask would be how to extend this to also also display title and description - from the metadata of the file
Thanks
I assume the original question of this thread is resolved, for the new question, please check the new thread:
https://toolset.com/forums/topic/display-title-and-description-from-the-metadata-of-the-pdf-file/