mcguffin / pdf-renderer
WordPress plugin to convert PDFs to Images before uploading them
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 6
Language:JavaScript
Type:wordpress-plugin
Requires
- intervention/httpauth: ^3.0
- mcguffin/wp-skeleton-asset: dev-main
- mcguffin/wp-skeleton-plugin: dev-main
- dev-master
- 0.1.0
- dev-dependabot/npm_and_yarn/minimist-1.2.8
- dev-dependabot/npm_and_yarn/json5-2.2.3
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/loader-utils-2.0.4
- dev-dependabot/npm_and_yarn/shell-quote-1.7.3
- dev-dependabot/npm_and_yarn/cached-path-relative-1.1.0
This package is auto-updated.
Last update: 2024-03-28 07:59:37 UTC
README
Convert PDF Files to Images in your browser when dropped into the media library.
Includes Mozilla pdf.js for browser pdf rendering.
PDF-Contents: cc-by Creative Commons
Installation
Production (using Github Updater – recommended for Multisite)
- Install Andy Fragen's GitHub Updater first.
- In WP Admin go to Settings / GitHub Updater / Install Plugin. Enter
mcguffin/pdf-renderer
as a Plugin-URI.
Development
- cd into your plugin directory
- $
git clone git@github.com:mcguffin/pdf-renderer.git
- $
cd pdf-renderer
- $
npm install
- $
npm run dev
Plugin API
Filter pdf_renderer_image_width
Use this to overrule width of generated images. Uses the largest image width known to WP by default. (e.g. the Large size from Settings > Media).
Example:
add_filter( 'pdf_renderer_image_width', function( $width ) { // never underestimate a good integer. return 12345; });
Filter pdf_renderer_image_type
Type of generated images. Possible values are image/png
and image/jpeg
. default is image/png
.
To override the JPEG-Quality you can use the WP Core filter jpeg_quality
. The string pdf_renderer
is passed as a second argument to apply_filters()
.
Example:
// we want jpeg ... add_filter( 'pdf_renderer_image_type', function( $type ) { return 'image/jpeg'; }); // ... and a specific treatment for PDFs. add_filter( 'jpeg_quality', function( $quality, $context = '' ) { if ( 'pdf_renderer' === $context ) { // Everybody loves artifacts. return 1; } return $quality; }, 10, 2);