Rapls PDF Image Creator automatically generates thumbnail images when you upload PDF files to your WordPress Media Library. The plugin uses ImageMagick (Imagick PHP extension) to convert the first page of a PDF into an image.
When you upload my-document.pdf, the plugin creates:
[rapls_pdf_thumbnail id="123"] – Display thumbnail image[rapls_pdf_thumbnail_url id="123"] – Output thumbnail URL[rapls_pdf_clickable_thumbnail id="123"] – Thumbnail linked to PDF[rapls_pdf_download_link id="123"] – Download link with thumbnailrapls_pic_get_thumbnail_url( $pdf_id, $size ) – Get thumbnail URLrapls_pic_get_thumbnail_id( $pdf_id ) – Get thumbnail attachment IDrapls_pic_get_thumbnail_image( $pdf_id, $size, $attr ) – Get thumbnail HTMLrapls_pic_has_thumbnail( $pdf_id ) – Check if PDF has thumbnailrapls_pic_generate_thumbnail( $pdf_id, $force ) – Generate thumbnailMost shared hosting providers have ImageMagick available. Check the Status tab in plugin settings to verify your server meets the requirements.
Display a PDF thumbnail in your theme:
$pdf_id = 123;
if ( rapls_pic_has_thumbnail( $pdf_id ) ) {
echo rapls_pic_get_thumbnail_image( $pdf_id, 'medium' );
}
Link thumbnail to PDF file:
$pdf_id = 123;
if ( $thumbnail_id = get_post_thumbnail_id( $pdf_id ) ) {
echo '<a href="' . esc_url( wp_get_attachment_url( $pdf_id ) ) . '" target="_blank">';
echo wp_get_attachment_image( $thumbnail_id, 'medium' );
echo '</a>';
}
$pdfs = get_posts( array(
'post_type' => 'attachment',
'post_mime_type' => 'application/pdf',
'post_parent' => get_the_ID(),
'posts_per_page' => -1,
) );
foreach ( $pdfs as $pdf ) {
if ( rapls_pic_has_thumbnail( $pdf->ID ) ) {
printf(
'<a href="%s">%s</a>',
esc_url( wp_get_attachment_url( $pdf->ID ) ),
rapls_pic_get_thumbnail_image( $pdf->ID, 'thumbnail' )
);
}
}
rapls_pdf_image_creator_thumbnail_page – PDF page to use (default: 0)rapls_pdf_image_creator_thumbnail_max_width – Maximum widthrapls_pdf_image_creator_thumbnail_max_height – Maximum heightrapls_pdf_image_creator_thumbnail_quality – Image quality (1-100)rapls_pdf_image_creator_thumbnail_format – Output formatrapls_pdf_image_creator_thumbnail_bgcolor – Background colorrapls_pdf_image_creator_thumbnail_image_attributes – Image tag attributesrapls_pdf_image_creator_custom_insert_html – Custom insert HTMLrapls_pdf_image_creator_hide_thumbnails_in_library – Hide in Media Libraryrapls_pdf_image_creator_before_generate – Before thumbnail generationrapls_pdf_image_creator_after_generate – After successful generationrapls_pdf_image_creator_generation_failed – When generation fails