Giter VIP home page Giter VIP logo

pdfthumb's Introduction

PDFThumb plugin for Craft CMS 3.x & 4.x

PDF thumbnail generation for Craft CMS 3 and Craft CMS 4

Usage

The craft.PDFThumb.thumbnail() template tag returns a URL to the generated thumbnail.

{% for myAsset in item.assetRef %}
    <img src="{{ craft.PDFThumb.thumbnail(myAsset) }}">
    <img src="{{ craft.PDFThumb.thumbnail(myAsset, 100, 100) }}">
    <img src="{{ craft.PDFThumb.thumbnail(myAsset, 100, 150, true, 'jpg') }}">
{% endfor %}

Heavily based on https://github.com/carnesmedia/pthumb

PThumb

PThumb is a Craft plugin that generates thumbnail preview images for PDF documents. It's easy to drop into your templates, requires only the commmand-line version of ImageMagick (not the PHP bindings), and caches the generated thumbnails.

It's still very much a work in progress, so use it in production environments at your own risk.

Installation

  1. Download the ZIP file
  2. Unzip it and move the pthumb folder to craft/plugins
  3. Install the plugin from the Plugins page of your control panel
  4. Click on the PThumb link on the plugins page to configure the plugin

Configuration

Setting Description
Storage Path Absolute or relative path to the storage directory for PDFs on the server, ex ~/craft/public/uploads/pdfs
Base URL URL to the storage path, ex /uploads/pdfs

Usage

The craft.PThumb.thumbnail() template tag returns a URL to the generated thumbnail.

<img src="{{ craft.PThumb.thumbnail(myAsset) }}">
<img src="{{ craft.PThumb.thumbnail(myAsset, 100, 100) }}">
<img src="{{ craft.PThumb.thumbnail(myAsset, 100, 150, true, 'jpg') }}">

The arguments, in order, are:

Argument Description
Asset Required
Width In pixels, default: 250
Height In pixels, default: 250
Exact size Force the canvas to exactly match the height/width specified by extending transparent (PNG) or white (JPG) space to the dimensions, useful for producing square images of rectangular documents, default: false
File format Options are 'png' or 'jpg', default: png

Known issues

  • Files must be limited to a single directory
  • Files must be stored locally

pdfthumb's People

Contributors

jmoont avatar tobinski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.