Skip to content

Store figure image derivative dimensions and paths on derivatives property#1235

Open
cbutcosk wants to merge 22 commits into
mainfrom
feature/figures-media-transformations-property
Open

Store figure image derivative dimensions and paths on derivatives property#1235
cbutcosk wants to merge 22 commits into
mainfrom
feature/figures-media-transformations-property

Conversation

@cbutcosk

@cbutcosk cbutcosk commented May 12, 2026

Copy link
Copy Markdown
Collaborator

This PR refactors the figure media model to make it easier to use image derivatives generated during publication builds. It moves path and dimension metadata handling into the higher-order FigureMedia class, allowing for more correct re-use of the paths in components and adding long-missing height and width attributes to quire's figure img tags, improving page responsiveness.

Overview of changes:

  • Adds a derivatives property to the media() data shim on FigureMedia class. derivatives contains an object with derivative transformation names as keys (full, thumbnail, etc) and result metadata (height, width, and asset paths) objects. A full list of transforms is in packages/11ty/_plugins/figures/iiif/config.js.
  • This is the shape of the additional data on FigureMedia instances serialized as JSON:
{
  "derivatives": {
    "full": {
      "dimensions": {
        "height": 1000,
        "width": 1000
      }
      "paths": {
        "absolute": "/_assets/images/XXX.jpg",
        "internal": "/subpath/_assets/images/XXX.jpg",
        "uri": "https://example.org/subpath/_assets/images/XXX.jpg"
      }
    }
  }
}
  • paths contains asset paths for derivatives:
    • absolute - relative to the the root of the publication hostname
    • internal - relative to the root of the publication (ie, paths that are safe to use in fragments that will be processed by the asset bundling plugin)
    • uri - with scheme, hostname, and port
  • dimensions contains the height and width for the derived image
  • Moves path calculations out of components and into FigureMedia methods. The switching dispatch of the figureElement component is also refactored so that control flow branches within the static figure tag are reduced from several branches to one branch with a varying argument.
  • Deletes now-redundant path calculations from imageTag and the print output mode of figureImage components.
  • Adds a helper function, snakeCaseToCamel, for converting transformation names within in the IIIF configuration that are in snake case to the camel case used by quire's data APIs (and enforced by linting, etc).
  • Adds tests for image asset paths to ensure correct behavior with and without a publication pathname.
  • Adds test ensuring that figure images with an HTTP URL as src but not an internally-served IIIF URL (eg, images on a CDN) use the src URL for all paths.

Affected Issues:

@cbutcosk cbutcosk changed the base branch from main to feature/figures-static-inline-for-all May 12, 2026 14:07
@cbutcosk cbutcosk changed the title Adds transformations property with computed paths for figure image assets Store figure image derivative dimensions and paths on transformations property May 18, 2026
@cbutcosk cbutcosk marked this pull request as ready for review May 18, 2026 18:33
Base automatically changed from feature/figures-static-inline-for-all to main May 21, 2026 17:05
@cbutcosk cbutcosk requested a review from geealbers May 21, 2026 17:06
@geealbers

Copy link
Copy Markdown
Member

@cbutcosk I ran this through my normal QA process and everything is looking good.

  1. Is there any documentation that should be added to _plugins/figures/README.md, _plugins/figures/schema.json or any other location in the code base to capture the information in your description of this PR or just to document things for our future selves?

  2. I'm going to post new issues about removing the duplicate figure image files from build that I surfaced in the previous PR, and about adding values to config.yaml for the derivative image sizes. Both for follow-up at a later date. Anything else you'd like to add as a follow-up issue that we might want to address in the future?

@cbutcosk cbutcosk force-pushed the feature/figures-media-transformations-property branch from 776caee to 7b8982a Compare June 4, 2026 18:24
@cbutcosk cbutcosk changed the title Store figure image derivative dimensions and paths on transformations property Store figure image derivative dimensions and paths on derivatives property Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants