Show PDF media file as embed object

Content Views Pro helps you to show any WordPress media files easily.
If you have PDF files, WordPress will try to create a thumbnail image on uploading process. In case it couldn’t create a thumbnail, a small icon will be displayed when you show thumbnail of the PDF files.

To replace the thumbnail image or icon by an embedded object (which shows the full content of the PDF file), please add this code to file functions.php in the theme’s folder:

// Content Views Pro - Show PDF media as embed object
add_filter( 'pt_cv_attachment_thumbnail', 'cvp_theme_pdf_preview', 100, 3 );
function cvp_theme_pdf_preview( $attachment, $post, $dimensions ) {
	$pdf = wp_get_attachment_url( $post->ID );
	if ( strpos( $pdf, '.pdf' ) !== false ) {
		$attachment = sprintf( '<object data="%1$s" type="application/pdf" width="100%%" height="100%%"><p>This browser does not support PDFs. Please <a href="%1$s">Download file</a>.</p></object>', esc_url( $pdf ) );
	}

	return $attachment;
}

Best regards,