Skip Navigation

[Résolu] Displaying preview images of uploaded PDF

This support ticket is created Il y a 6 années et 1 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Marqué : 

This topic contains 7 réponses, has 3 voix.

Last updated by Dan Kitsmiller Il y a 6 années et 1 mois.

Assisted by: Noman.

Auteur
Publications
#625087
1-Upon page load.png
2-After applying filter.png

I'm trying to display thumbnails of uploaded PDF documents using the code in this resolved thread:
https://toolset.com/forums/topic/how-to-display-thumbnails-of-of-pdfs-uploaded-to-the-types-document-field/

The thumbnails display as expected when the page is initially displayed, but if a user filters the results, a broken link is displayed. Here is a link to the page in question (click on the "Carrier Documents" tab):
hidden link

The thumbnails are displayed in the left column as expected. Now try displaying only documents from "AXA", for example, and apply the filter. The thumbnail links are now broken.

I'm using the code from the aforementioned thread exactly as provided. Can you point me in the right direction on how to resolve this? Thanks!

BTW, it would be great if Views offered previews of uploaded PDFs as a built-in option, now that WordPress supports them.

#625145

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Yes, I can able to reproduce the issue which you mentioned with the problem URL you shared.

I need to check whats going wrong there with your setup and why it's not loading the image with filter. Have you setup filter as AJAX filter?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#627073

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked and I debug the issue but I see there is no option to display preview image with AJAX views.

I'll pass this ticket to Noman as he should know more about the solution he shared with you and maybe how to fix this issue.

#627475

Hi, the client would like me to provide a timeline for this fix - can you let me know?

#627497

Thank you - if you can provide a timeline, that would also be great!

#628440

Noman
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Minesh has passed me this ticket as I originally write that code. I am trying to see what needs to be changed in it to make it work and I will get back to you shortly.

Thank you for your patience.

#628740

Noman
Supporter

Languages: Anglais (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello Dan Kitsmiller,

I have updated following code:

// Render image of PDF Uploads
function getPDFimg($atts) {
             
             extract( shortcode_atts( array(
            'size'=>'full',
			'url'=>''
        ), $atts ) );
		
             
          //  $image_url = str_replace(".pdf", ".jpg", types_render_field( "document")); // publication_document = your field name
		  
		    $image_url = str_replace(".pdf", ".jpg", $atts['url']); // publication_document = your field name
			
            $dirname = str_replace('.jpg','',str_replace(home_url('/'),'',$image_url));
			
            $images = glob($dirname."*.jpg");
			
            if(empty($images)) {
				$images = glob('../'.$dirname."*.jpg");
			}

			if(isset($images[0])){
						$small_image = home_url('/').$images[0];
			}
			if(isset($images[1])) {
						$medium_image = home_url('/').$images[1];
			}
			if(isset($images[2])) {
						$large_image = home_url('/').$images[2];
			}
			
			
             
            switch($size) {
                        case 'small':
                                    if(isset($small_image) && $small_image != '' ) {
                                                $image_src = $small_image;      
                                    }
                                    else{
                                                $image_src = $image_url;
                                    }
                        break;
                         
                        case 'medium':
                                    if(isset($medium_image) && $medium_image != '' ) {
                                                $image_src = $medium_image;  
                                    }
                                    else{
                                                $image_src = $image_url;
                                    }
                        break;
                         
                        case 'large':
                                    if(isset($large_image) && $large_image != '' ) {
                                                $image_src = $large_image;      
                                    }
                                    else{
                                                $image_src = $image_url;
                                    }
                        break;
                         
                        default:
                                    $image_src = $image_url;
                                                 
            }
			             
    return '<img src=' .$image_src  . ' class="pubdoc-pdf-image"> ';
}
  
add_shortcode('getpublicationpdfimg', 'getPDFimg'); 

And issue got fixed. Can you please check and confirm?

Thank you

#631629

Thanks, that solved the problem!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.