I could be incorrect, but I think if you want the pdf to show like that, you’d need to save it as an image and then wrap the image with the pdf link if that makes sense? Hope that helps.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
I think WordPress generates a thumbnail for the PDF* already, but I’m not sure why it’s not being pulled into the template.
Try deactivating all of your plugins to explore whether any could be responsible. If none are, keep all plugins deactivated and switch to the Twenty Seventeen theme to check whether it’s an issue with your theme.
So.
I just make this filter as workaround
function _add_media_pdf_thumbnail( $html, $id, $attach ) {
$file_url = $attach['url'];
$filetype = wp_check_filetype( $file_url );
if( $filetype['ext'] == 'pdf' ){
$thumb_url = wp_get_attachment_image_src( $id, 'medium' );
$_html = '';
$_html .= '<a href="'.$file_url.'" target="_blank">';
$_html .= '<img src="'.$thumb_url[0].'" />';
$_html .= '</a>';
return $_html;
}
return $html;
}
add_filter( 'media_send_to_editor', '_add_media_pdf_thumbnail', 10, 3 );
But looking at WordPress source, the thumbnail is only added for images, not other type of media.
See https://developer.wordpress.org/reference/functions/wp_ajax_send_attachment_to_editor/