Skip to content

Binary field image editor resolves the wrong field variable (parent titleImage) and 404s #36426

Description

@oidacra

Description

In the new Edit Content, opening the image editor from a Binary field whose value was hydrated from a saved contentlet renders a broken preview ("We couldn't render the preview. Please try again."), and saving from that state stages a temp file with unusable metadata (the preview then falls back to the type icon instead of the edited image).

Root cause

DotFileFieldComponent.onEditImage() resolves the field variable for the editor URLs as:

const editorVariable =
    uploaded?.source === 'contentlet'
        ? String(uploaded.file['titleImage'] ?? variable)
        : variable;

For a Binary field on a saved contentlet, the store hydrates the preview with the parent contentlet (setFileFromContentlet), so uploaded.file is the parent and its titleImage points at the content type's first image-ish field — which can be an Image reference field (stores a dotAsset identifier, holds no binary). The editor then requests /contentAsset/image/{parentInode}/{titleImage}/... and gets a 404.

The titleImage fallback is only correct for standalone assets (dotAsset via getAssetData, AI-generated images), where the image does live in the asset's own titleImage field.

Steps to reproduce

  1. Content type with an Image (reference) field ordered before a Binary field (e.g. the QA type: image, ..., binaryImage).
  2. Save a contentlet with both fields populated.
  3. Reopen it in the new Edit Content and click the Binary field's Edit (pencil) action.
  4. The editor preview fails to render; requests to /contentAsset/image/{inode}/image?... return 404. Saving from that state degrades the preview thumbnail to the type icon.

Proposed fix

Prefer the field variable the store already injects when hydrating from the parent contentlet, falling back to titleImage only for standalone assets (which carry no injected fieldVariable):

const editorVariable =
    uploaded?.source === 'contentlet'
        ? String(uploaded.file['fieldVariable'] ?? uploaded.file['titleImage'] ?? variable)
        : variable;

Verified live: Binary editor preview renders and the save round-trip applies the edit; Image/File fields (dotAsset, no injected fieldVariable) keep the titleImage resolution and are unaffected.

Priority

Medium

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions