I have an improved experimental version of the “Google File Viewer replacement” feature:
- The “Imagemagick thumbnail” implementation is faster and more reliable.
- You can now assign a “Featured Image” to any Media Library item, such as a PDF document. If you do, the image is used a thumbnail for the item instead of generating an “Imagemagick thumbnail” on the fly.
I am still working on some other aspects of this project:
- Detect missing Ghostscript support without crashing the server.
- Use Imagemagick to generate an PDF single-page image manually, saving it as a Media Library item that can become the “Featured Image” of the document without on-the-fly delays.
- Add some hooks to give more control over the various options.
The new “mla_viewer” feature has several parameters:
mla_viewer
– set this to “true” to activate the viewer.
mla_viewer_extensions
– set this to txt
to prevent PDF processing when Ghostscript is not installed but Imagick is installed.
mla_viewer_limit
– set this to a value in MB to limit PDF processing to files smaller than the parameter value.
mla_viewer_width
– set this to a positive value to limit the width of the generated thumbnails.
mla_viewer_height
– set this to a positive value to limit the height of the generated thumbnails.
mla_viewer_page
– set this to 2 or higher to select that document page as the thumbnail. Default is the first/only document page.
mla_viewer_resolution
– set this something higher than the default (72) to increase the quality of the thumbnail image; try 200 or 300.
mla_viewer_type
– set this to “image/png” to return thumbnails in that format; default is “image/jpeg”.
If you set neither mla_viewer_width
nor mla_viewer_height
, the default process will return thumbnails with a width of 150px and a proportional height. If you set both, the image will be exactly the height and width you set, which may distort some images.
If you set mla_viewer_resolution
to a high value the images will look great but take longer to process.
If you set mla_viewer_type
to “image/png” the background will be transparent and image generation may be slightly faster. The default jpeg images will have a white background.