Media PDF Thumbnail

Module Drupal Illustration Voir sur Drupal.org
Nb téléchargements : 1750

Components

  • Code
  • Documentation
  • Miscellaneous
  • User interface

Documentation

Images





Licence

http://www.gnu.org/licenses/old-licenses/gpl-2.0.html

permet de générer une ou des vignettes image via un pdf

Release

Status : Published
Projects : Modules
Maintenance status : Minimally maintained
Development status : Maintenance fixes only
Supported Branches : 6.0., 8.x-5.
shield Stable releases for this project are covered by the security advisory policy.






Description

The module provides an image field formatter for the thumbnail field of Media entities. The default thumbnail image will be replaced by an image generated from a pdf file referenced in any file field of the Media entity.

Prerequisite :
imagick PHP extension.
spatie/pdf-to-image library: composer require spatie/pdf-to-image.

Instructions :
Install as you would normally install a contributed Drupal module and enabled it.
Install spatie/pdf-to-image: composer require spatie/pdf-to-image
That library has a known issue making some images with failed colors.
A working patch has been proposed here : https://www.drupal.org/project/media_pdf_thumbnail/issues/3221786#commen...

Usage :
Choose the "Media PDF Thumbnail Image" field formatter in the Media entity view mode for thumbnail field and set desired options.
When rendering the thumbnail field, the image from the file field (the one choosen in the field formatter's options) will be created and stored in a storage entity.
When the thumbnail field is rendered, the image file will be fetched from the storage entity. The original image of the thumbnail field is never modified.
Don't forget to clear caches after any changes for rebuilding the field render.

Token :

Getting values :
// @value can be "image_uri" or "image_id"
[media_pdf_thumbnail:@pdf_field_name:@pdf_page:@value]

Getting render :
[media_pdf_thumbnail:@pdf_field_name:@pdf_page:render:@image_style]

Getting render and link image to pdf file :
[media_pdf_thumbnail:@pdf_field_name:@pdf_page:render:@image_style:link_pdf]

Examples :

// Returns image file uri
$fileUri = Drupal::token()->replace('[media_pdf_thumbnail:field_media_file:1:image_uri]', ['media' => $media]);
// Returns image file id
$fileId = Drupal::token()->replace('[media_pdf_thumbnail:field_media_file:1:image_id]', ['media' => $media]);
// Returns image html render
$render = $token->replace('[media_pdf_thumbnail:field_media_file:1:render:medium]', ['media' => $media]);
// Returns image linked to pdf html render
$renderLink = $token->replace('[media_pdf_thumbnail:field_media_file:1:render:medium:link_pdf]', ['media' => $media]);

Configuration:
The list of the stored entities can be found here : Administration » Configuration » Multimedia » Media PDF Thumbnail (/admin/media-pdf-thumbnail/settings/list).
You can see all details concerning Media entities using the pdf image thumbnail. Those entities can be deleted individually or fully cleaned. Basically they are used to store all datas from image generation.

Updates

From 5.x to 6.x

  • Use composer to update the module
  • Run a database update
  • Clear caches

See documentation for new features.

From 4.x and below to 5.x or 6.x
Versions below 5.x are no more supported and are not compatible for a direct update.
IMPORTANT:You must uninstall them before installing 5.x or 6.x.



Toutes les informations proviennent du site drupal.org