Problem/Motivation

Currently there is no relationship between uploaded PDFs and generated previews. The previews is generated on demand based on the module's filename settings and we can't reliably determine which previews belongs to which PDF, particularly when using md5 filenames. In particular, this is a blocker for #2553845: Preview image should use same file system as that of its parent PDF.

Proposed resolution

Generate the preview when the PDF is created/updated and store it in managed files. Also ensure the preview is deleted when the PDF is deleted. We probably also need to keep the on-demand generation for previews that haven't been created yet, e.g. due to module upgrades, config changes, etc.

Remaining tasks

  • Determine which PDFs should have a preview generated, possibly via field config
  • Implement CRUD hooks for file entities
  • Save the generated preview to managed files
  • Record file usage of the preview, possibly against the PDF file entity, or the entity the file is attached to
  • Update script
  • Tests

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Original report by PascalAnimateur

Is there a specific reason why the generated thumbnail image isn't created as a managed file? This would allow using it as any other image throughout the site without relying on pdfpreview to display it...

Comments

helmo’s picture

Title: Thumbnail as managed file » Preview image as managed file

+1 It would also open up a way to do access checks.

PS: changing the title as the generated preview image can have a thumbnail of it's own ;)

mstrelan’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
mstrelan’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

I've opened up a 2.0.x branch for this feature.

mstrelan’s picture

Issue summary: View changes