Skip to content

Placeholder

Jan Hermann edited this page Oct 9, 2026 · 1 revision

🧩

Built-in fallback image served from the bundle, without a route and without assets:install.

When a source image is missing or can not be processed, thumbnail() returns the URL /_imagony/no-image.png (a grey 600×400 picture icon). Set fallback in the configuration to use your own image instead.

Final class with the URL and file of the placeholder.

  • Placeholder::URL: /_imagony/no-image.png.
  • Placeholder::file(): string: absolute path of the PNG in the bundle (resources/no-image.png).
  • Placeholder::resolve(string $path): ?array: for the URL of the placeholder or of its .webp / .avif variant returns ['file' => ..., 'type' => ...], otherwise null.

kernel.request listener (priority 256) that answers before the router, so there is no route to import.

  • The WebP and AVIF variants are served too, so <source srcset="{{ thumbnail(...) }}.webp"> works for the placeholder.
  • Responses are public and cacheable (max-age one day, ETag, Last-Modified). Only cacheable methods (GET, HEAD) of the main request are answered.
  • The URL is absolute, so the application has to run at the root of the domain.
  • The web server has to pass the URL to public/index.php, which is the default for Symfony.

Own fallback image

imagony:
    thumbnails:
        fallback: '%kernel.project_dir%/public/images/no-image.png'

The file has to be inside base. Its URL is the path relative to base and it is converted to formats like any thumbnail. imagony:check warns when the file is missing or outside base.

Clone this wiki locally