Skip to content

[BUG] autogenerate images are created for every crop variant but dropped from the output #912

Open

Description

@dvdmlln

Describe the bug

FileUtility::processCropVariants() processes every crop variant through FileUtility::process() and passes the full ProcessingConfiguration along, autogenerate included. process() therefore runs processAutogenerate() for each variant and creates a ProcessedFile per configured factor. cropVariant() then assembles the entry from the url and the dimensions only, so the autogenerate keys are dropped.

The images are rendered and stored, but no URL to them ever reaches the payload.

Meanwhile the top level keeps its urlRetina, where it is least useful: with no explicit width/height in the processing configuration, processAutogenerate() clamps the target to the source dimensions (since the fix for #830, to the crop area), so the generated file is pixel-identical to publicUrl — a second ProcessedFile of the same image.

To Reproduce

  1. A CE with an image field whose TCA defines two crop variants, e.g. mobile and desktop
  2. TypoScript:
    dataProcessing.10 = FriendsOfTYPO3\Headless\DataProcessing\FilesProcessor
    dataProcessing.10 {
        references.fieldName = image
        as = files
        processingConfiguration {
            autogenerate.retina2x = 1
        }
    }
    
  3. Crop both variants in the backend, then render the page
  4. Look at sys_file_processedfile: one 2x file has been created per crop variant
  5. Look at the JSON: urlRetina is present on the top level only; the cropVariants entries carry publicUrl and dimensions

Expected behavior

Either the autogenerate URLs are carried into the crop variant entries, or they are not generated for crop variants at all. Right now the processing cost is paid and the result is unreachable.

Propagating them seems the more useful of the two: since #830 the per-variant images are clamped to the crop area, so they are correct to expose, and they are exactly what a responsive srcset per breakpoint needs.

A smaller, related point — happy to split it into its own issue: when the computed autogenerate size equals the source size, which is always the case on the top level when no width/height is configured, the generated image is a duplicate. Skipping generation in that case would avoid the extra ProcessedFile.

I am happy to prepare a PR if you would like this fixed — just let me know which of the two directions you prefer, carrying the URLs into the crop variant entries or not generating them there.

TYPO3 version and TYPO3 Headless version

  • TYPO3 13.4
  • EXT:headless 4.8.1

The code paths are unchanged in v5.0.0-rc2.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions