Skip to content

Hacky code exists to preload draft images #5799

Description

@KludgeKML

Introduced in #5789

In early September 2026, Whitehall shipped a change to images to bring them in line with attachments: they’re now uploaded to the draft stack by default, only being made live when the associated document is published. Access-limiting and auth-bypass options are proliferated through to the images too.

Where a document embeds more than one image, a user visiting the page ‘cold' will be missing the session cookie for the asset manager, and all of the images on the page will each independently try to set up the session. The handshakes and callbacks all happen in a non-deterministic order, and more often than not, the authentication step fails. The result is a page with a number of draft images that simply don’t render, even with a refresh or a cookie clear.

The PR fixes this by waiting for a page load event, checking if there are at least two images on the page, then dynamically requesting a known good draft asset. This forces a session to be established, at which point the images in the page can be reloaded.

When can we pay it down?

Likely paydown is when signon can set up all required sessions on the asset server on login (the way it does for the pages themselves). Whitehall are tracking this work here: https://gov-uk.atlassian.net/browse/PTD-166

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtPull requests which introduce tech debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions