[WordPress] 外掛分享: PDF Thumbnail Generator

首頁外掛目錄 › PDF Thumbnail Generator
WordPress 外掛 PDF Thumbnail Generator 的封面圖片
2,000+
安裝啟用
★★★★
4.3/5 分(6 則評價)
107 天前
最後更新
50%
問題解決
WordPress 3.0.1+ PHP 5.6+ v1.5 上架:2022-07-07

內容簡介

PDF Thumbnail Generator 可在 PDF 檔案上傳至媒體庫時自動產生縮圖,也能為既有的 PDF 批次建立或重新產生縮圖,並提供尺寸、畫質與格式等自訂設定,方便在網站前台展示 PDF 預覽圖。

【主要功能】
• 上傳 PDF 時自動產生縮圖
• 批次為既有 PDF 產生或重新產生縮圖
• 自訂縮圖最大寬度、高度與畫質
• 自訂縮圖輸出的圖片格式
• 提供多組短代碼顯示縮圖或可點擊連結
• 支援多站網路、子目錄及 Apache/NGiNX 環境

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.5) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「PDF Thumbnail Generator」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Generates thumbnail for PDF file automatically after file is uploaded to the Media library.
You can also generate thumbnails for old PDF files that are already in the Media library – you can generate missing thumbnails or regenerate all thumbnails.
Imagick library must be installed on your server, otherwise this plugin will not work

automated test after plugin activation to make sure it will work on your server
works with all types of WordPress installations: domain, subdomain, subdirectory, multisite/network
works on Apache and NGiNX
automatically generate thumbnail for new uploaded PDFs
(re)generate thumbnails for existing PDFs in Media library
set maximum width of PDF thumbnail
set maximum height of PDF thumbnail
set image quality of PDF thumbnail
set image file type of PDF thumbnail

Shortcodes
pdf_thumbnail
Maybe you want to display PDF thumbnail by using a shortcode
[pdf_thumbnail id="123"]

pdf_thumbnail_url
Maybe you want to display PDF thumbnail url by using a shortcode
[pdf_thumbnail_url id="123"]

pdf_clickable_thumbnail
Maybe you want to display clickable PDF thumbnail that will open PDF in new tab
[pdf_clickable_thumbnail id="123"]

 
Functions
get_pdf_thumbnail_url
If you want to return PDF thumbnail URL you can use
get_pdf_thumbnail_url( $pdf_id )

it works similar to wp_get_attachment_url and it will return something like
https://site.com/wp-content/uploads/2022/01/example.pdf.png

get_pdf_thumbnail_path
If you want to return PDF thumbnail URL you can use
get_pdf_thumbnail_path( $pdf_id )

it works similar to get_attached_file and it will return something like
/www/site.com/wp-content/uploads/2022/01/example.pdf.png

get_pdf_thumbnail_image_src
If you want to return PDF thumbnail url, width and height you can use
get_pdf_thumbnail_image_src( $pdf_id )

it works similar to wp_get_attachment_image_src and it will return something like
[
0 => 'https://site.com/wp-content/uploads/2022/01/example.pdf.png',
1 => 600,
2 => 800
]

get_pdf_thumbnail_image
If you want to return PDF thumbnail image tag you can use
get_pdf_thumbnail_image( $pdf_id )

it works similar to wp_get_attachment_image and it will return something like
example

 
Hooks
pdf_thumbnail_max_width
Maybe you want to change global PDF thumbnail max_width for a specific PDF file
add_filter( 'pdf_thumbnail_max_width', function( $max_width, $pdf_id ){
if( $pdf_id == 123 ){
return 1024;
}
return $max_width;
}, 10, 2 );

pdf_thumbnail_max_height
Maybe you want to change global PDF thumbnail max_width for a specific PDF file
add_filter( 'pdf_thumbnail_max_height', function( $max_height, $pdf_id ){
if( $pdf_id == 123 ){
return 768;
}
return $max_height;
}, 10, 2 );

pdf_thumbnail_quality
Maybe you want to change global PDF thumbnail quality for a specific PDF file
add_filter( 'pdf_thumbnail_quality', function( $quality, $pdf_id ){
if( $pdf_id == 123 ){
return 100;
}
return $quality;
}, 10, 2 );

pdf_thumbnail_type
Maybe you want to change global PDF thumbnail file type for a specific PDF file
add_filter( 'pdf_thumbnail_type', function( $type, $pdf_id ){
if( $pdf_id == 123 ){
return 'png'; // or 'jpg'
}
return $type;
}, 10, 2 );

pdf_thumbnail_bgcolor
Maybe you want to change default PDF thumbnail background for a specific PDF file
add_filter( 'pdf_thumbnail_bgcolor', function( $bgcolor, $pdf_id ){
if( $pdf_id == 123 ){
return 'black'; // default is 'white'
}
return $bgcolor;
}, 10, 2 );

pdf_thumbnail_page_number
Maybe you want to PDF thumbnail page number for a specific PDF file
add_filter( 'pdf_thumbnail_page_number', function( $page, $pdf_id ){
if( $pdf_id == 123 ){
return 1; // default is 0
}
return $page;
}, 10, 2 );

pdf_thumbnail_filename
Maybe you want to PDF thumbnail filename for a specific PDF file
add_filter( 'pdf_thumbnail_filename', function( $filename, $pdf_id ){
if( $pdf_id == 123 ){
return str_replace( '.pdf.png', '.png', $filename );
}
return $filename;
}, 10, 2 );

pdf_thumbnail_imagick
Maybe you want to add watermark to PDF thumbnail for a specific PDF file
add_filter( 'pdf_thumbnail_imagick', function( $imagick, $pdf_id ){
if( $pdf_id == 123 ){
// add your watermark here
}
return $imagick;
}, 10, 2 );

get_pdf_thumbnail_image_attributes
Maybe you want to change attributes for image tag from get_pdf_thumbnail_image function
add_filter( 'get_pdf_thumbnail_image_attributes', function( $attr, $pdf_id ){
$attr['loading'] = 'eager';
return $attr;
}, 10, 2 );

pdf_thumbnail_generated
Maybe you want to do something after the thumbnail is generated
add_action( 'pdf_thumbnail_generated', function( $thumbnail_path, $pdf_id ){
// do somthing with the local file $thumbnail_path
}, 10, 2 );

延伸相關外掛

文章
Filter
Apply Filters
Mastodon