Module 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.

Project Usage
1747
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
Production
Module Summary
This module aims to provide an image field formatter for the thumbnail field of Media entities, replacing the default thumbnail image with an image generated from a pdf file referenced in any file field of the Media entity.
Data Name
media_pdf_thumbnail

OPENAI CHATBOT

OPENAI CHATBOT

16:30:42
Generic Chatbot
Hi, I'm a Drupal module expert powered by OpenAI, answering your questions about the Drupal module ecosystem. How can I be helpful today? Please note that we will log your question.