## Problem

The module generates PDF page images sized to the width/height configured in
the formatter settings. These images are cached in the database keyed only by
`pdf_file_id` and page count - dimensions are not part of the cache key.

This causes two related bugs:

1. **Changing dimensions has no effect.** If you update the width/height in the
field display settings, `data-width` and `data-height` are correctly updated
in the DOM, but the AJAX endpoint returns the already-cached images generated
with the previous dimensions. The only workaround is to manually flush all
generated images via `/admin/pdf-slideshow/delete`.

2. **Multiple display modes share the same sized image.** If two display modes
(e.g. "default" and "teaser") configure different dimensions for the same
field, whichever runs first wins. The second display mode silently receives
images sized for the first, because the cache check is:

if (count($urls) != intval($limit))

...which only compares page count, never dimensions.

The image filename itself confirms the issue - it contains no dimension
information:

sites/default/files/pdf_slideshow/2026-06/my-file.pdf-0.png

## Proposed solution

Replace the custom width/height generation with Drupal's image style system:

1. **Generate original images once** - Imagick converts each PDF page to a
full-resolution PNG stored as a managed file, keyed only by `pdf_file_id`
and page index. Dimensions play no role at this stage.

2. **Apply image styles for output** - The formatter settings expose an
"Image style" selector (standard Drupal pattern, used by every core image
formatter). The AJAX render endpoint applies the selected style to produce
sized derivatives.

This approach:
- Fixes the stale-dimensions bug: changing the image style flushes derivatives
only, not the expensive Imagick-generated source images
- Fixes the multiple display modes bug: each display mode selects its own
image style independently
- Removes duplicated logic that Drupal's image style system already handles
(cache invalidation, CDN flushing, multiple derivatives)
- Aligns with Drupal conventions for image handling

Note: this is a breaking change to the AJAX endpoint URL structure, which
currently encodes dimensions as path parameters
(`/slideshow/render/{fids}/{width}/{height}/{nbpages}`). The width/height
segments would be replaced by an image style name.

Comments

vbouchet created an issue. See original summary.

vbouchet’s picture