insight-media / statamic-pdf-thumbnailer
A Statamic addon to automatically generate a thumbnail per uploaded PDF asset
v1.0.1
2023-09-08 21:59 UTC
Requires
- php: ^8.0
- spatie/pdf-to-image: ^1.2
This package is auto-updated.
Last update: 2024-10-09 00:26:19 UTC
README
Statamic Pdf Thumbnailer
Statamic Pdf Thumbnailer automatically generates an image per uploaded PDF asset.
Particularly useful when you want to show image previews when linking to PDF files.
Features
- Generates an image asset of the first page for every uploaded PDF
- The uploaded PDF contains a relation to the image asset
- Includes a page number selector, when an image preview other than the first page is needed
- Includes a simple tag to show the image previews in your antlers templates
Requirements
You should have Imagick and Ghostscript installed. See issues regarding Ghostscript on the underlying Spatie package page.
How to Install
You can search for this addon in the Tools > Addons
section of the Statamic control panel and click install, or run the following command from your project root:
composer require insight-media/statamic-pdf-thumbnailer
How to Use
In your antlers templates
For example, if you have an Assets fieldtype named 'catalogs', containing some Pdf's:
{{ catalogs }} <a href="{{ url }}"> <img src="{{ pdf :to="thumbnail" }}"> <!-- or when using glide: --> <img src="{{ glide src=thumbnail width="200" }}"> </a> {{ /catalogs }}