PHPackages                             alengo/sulu-translated-media-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. alengo/sulu-translated-media-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

alengo/sulu-translated-media-bundle
===================================

SEO-friendly translated media filenames for Sulu CMS

3.0.12(3w ago)063↓73.1%MITPHPPHP ^8.2CI passing

Since Apr 5Pushed 3w agoCompare

[ Source](https://github.com/alengodev/SuluTranslatedMediaBundle)[ Packagist](https://packagist.org/packages/alengo/sulu-translated-media-bundle)[ Docs](https://github.com/alengodev/SuluBlockSettingsBundle)[ RSS](/packages/alengo-sulu-translated-media-bundle/feed)WikiDiscussions 3.x Synced 3d ago

READMEChangelog (10)Dependencies (24)Versions (14)Used By (0)

SuluTranslatedMediaBundle
=========================

[](#sulutranslatedmediabundle)

SEO-friendly translated media filenames for [Sulu CMS](https://sulu.io/) 3.x.

Serves media files under locale-specific SEO filenames (e.g. `/uploads/red-shoes-de.jpg`) while keeping the original file stored under its original name. Includes an "Additional Data" admin tab with locale-aware title, description, and SEO filename fields — plus optional boolean flags (`verifyDownload`, `aiGenerated`).

Features
--------

[](#features)

- **Translated filenames** — per-locale `seoFilename`, `title`, `description` in `me_media_translations`
- **Built-in Media entity** — ready-to-use `Media` entity extending Sulu's base; no project entity required
- **TranslatedFormatManager** — replaces Sulu's default FormatManager via compiler pass
- **Twig functions** — `sulu_translated_media_url()` / `sulu_translated_media_urls()` with WebP support
- **Format cache warming** — pre-generates the format cache (jpg/webp/avif, x1 &amp; x2) for all image media under their translated filenames
- **Admin tab** — "Additional Data" tab auto-registered in the Sulu Media admin
- **Zero-config** — `sulu_media.objects.media.model` and `sulu_admin` resources are auto-configured

Requirements
------------

[](#requirements)

- PHP 8.2+
- Sulu CMS ~3.0
- Symfony 7.x

Installation
------------

[](#installation)

```
composer require alengo/sulu-translated-media-bundle
```

Register the bundle in `config/bundles.php`:

```
Alengo\SuluTranslatedMediaBundle\TranslatedMediaBundle::class => ['all' => true],
```

Import the admin API routes in `config/routes/sulu_admin.yaml`:

```
TranslatedMediaBundle:
    resource: "@TranslatedMediaBundle/Resources/config/routing_admin_api.yaml"
    prefix: /admin/api
```

Run a database migration or schema update to create the `me_media_translations` table:

```
bin/adminconsole doctrine:schema:update --force
```

That's it — no further configuration required.

Twig Usage
----------

[](#twig-usage)

```
{# Single URL with translated filename #}
{{ sulu_translated_media_url(media, '800x', app.request.locale) }}

{# With explicit format override #}
{{ sulu_translated_media_url(media, '800x', 'de', 'webp') }}

{# All format URLs (default + WebP) for use in  / srcset #}
{% set urls = sulu_translated_media_urls(media, '800x', app.request.locale) %}

```

Provided Models
---------------

[](#provided-models)

ClassPurpose`Entity\Media`Concrete Doctrine entity (`me_media`) — use directly or extend`Entity\MediaTranslations`Locale rows in `me_media_translations``Model\MediaTranslationsAwareInterface` + `MediaTranslationsTrait`Locale fields: `title`, `description`, `seoFilename``Model\MediaAdditionalDataInterface` + `MediaAdditionalDataTrait`Boolean flags: `verifyDownload`, `aiGenerated`Commands
--------

[](#commands)

### `alengo:translated-media:format-cache:warm`

[](#alengotranslated-mediaformat-cachewarm)

Pre-generates ("warms") the local format cache (`public/uploads/media`) for every image media, so the frontend never has to generate a thumbnail on the first request. Because the `TranslatedFormatManager` stores each rendition under the *URL filename*, the command warms one cache entry per distinct base filename: the original filename (covers every locale without a SEO override) plus the slugged `seoFilename` of every translation. For each base filename it warms both the x1 variant (e.g. `800x600`) and the x2 / retina variant (`800x600@2x`), each in `jpg`, `webp` and `avif` (intersected with the formats Sulu can actually produce for the source mime type).

**Which formats are warmed:** the base format keys are read from the source YAML (`config/app/image-formats.yaml` by default). If it defines a `warm_cache_image_formats:` list, **only** those formats are warmed — keep this to the handful your frontend actually requests so you don't waste time encoding every registered format. If that key is absent the command falls back to the full `image_formats:` list. Example:

```
# config/app/image-formats.yaml
image_formats:
    - '1920x1080'
    - '1280x800'
    - '800x600'
    # … every registered format

warm_cache_image_formats:   # the subset actually warmed
    - '1024x768'
    - '800x600'
    - '640x480'
    - '380x240'
```

**Media scope:** by default only media actually referenced by content (read from Sulu's `re_references` reference store, `resourceKey = "media"`) are warmed — uploaded-but-unused media are skipped. Pass `--no-referenced-only` to warm every image media; an explicit `--media` list always wins. If the reference table is missing the command falls back to all media (with a warning), and if it is empty it warns that references may not be indexed — so it never silently warms nothing.

```
bin/console alengo:translated-media:format-cache:warm                       # referenced media only (default)
bin/console alengo:translated-media:format-cache:warm --no-referenced-only  # every image media
bin/console alengo:translated-media:format-cache:warm --dry-run
bin/console alengo:translated-media:format-cache:warm --skip-existing
bin/console alengo:translated-media:format-cache:warm --media=1,42,99 --extensions=webp,avif
```

By default existing cache files are **overwritten** (re-encoded). Pass `--skip-existing` to leave already-cached renditions untouched and only generate the missing ones — much faster for incremental re-runs.

`jpeg` is accepted as an alias for `jpg` — Sulu normalises both to the `jpg` cache extension, so there is no separate `.jpeg` cache file.

OptionDefaultDescription`--source` / `-s``config/app/image-formats.yaml`Source YAML file with the base format keys, relative to project root (reads `warm_cache_image_formats:`, falling back to `image_formats:`)`--extensions` / `-x``jpg,webp,avif`Comma-separated output extensions to warm`--media` / `-m`*(all)*Restrict to a comma-separated list of media IDs (overrides `--referenced-only`)`--no-referenced-only`Warm **every** image media, not only those referenced by content (default: referenced only)`--formats`*(all)*Restrict to a comma-separated list of base format keys (a subset of the source file)`--no-2x`Skip the `@2x` / retina variants (halves the work)`--parallel` / `-j``1`Number of parallel worker processes`--no-decode-once`Disable the default decode-once strategy (decode the source once per rendition via the FormatManager)`--skip-existing`Skip renditions that already exist in the cache (faster re-runs)`--dry-run`List what would be generated without writing any file#### Performance

[](#performance)

Warming the full matrix (every media × every format × `@2x` × `jpg`/`webp`/`avif`) is CPU-heavy — AVIF encoding in particular. Several levers shorten the wall-clock time:

- **De-duplicated fan-out (always on)** — the converted bytes of a rendition depend only on the source, format key and extension, *not* on the (translated) URL filename. Each rendition is therefore encoded **once** and the identical bytes are written to every translated filename (original + each SEO name). For multilingual media with several SEO filenames this alone removes the bulk of the redundant conversions.
- **`--parallel=N`** — image conversion is single-threaded per PHP process. Spreading the media over `N` worker processes gives a near-linear speed-up on multi-core hosts. A good starting point is the number of CPU cores:

    ```
    bin/console alengo:translated-media:format-cache:warm --parallel=8 --skip-existing
    ```
- **Warm AVIF separately / off-peak** — AVIF is 10–50× slower to encode than `jpg`/`webp`. Warm the cheap formats first so the site is fast immediately, then warm AVIF in the background:

    ```
    bin/console alengo:translated-media:format-cache:warm --extensions=jpg,webp --parallel=8
    bin/console alengo:translated-media:format-cache:warm --extensions=avif   --parallel=8 --skip-existing
    ```

    To trade a little AVIF quality for a lot of speed, lower the encoder effort in your Sulu image-format `options` (e.g. an `avif`/`heic` `speed`/`quality` option, depending on your ImageMagick/Imagine build).
- **`--formats` / `--no-2x`** — only warm what the frontend actually requests. Restricting to the handful of formats used in your templates and dropping retina variants shrinks the matrix directly.
- **Decode-once (default, on)** — each source image is decoded a single time per media and reused across all formats and extensions, instead of re-loading and re-decoding the source for every rendition. Restricted to single-layer raster images; animated GIF/WebP, SVG and any decode failure transparently fall back to Sulu's regular converter, so the cached bytes always match the live image proxy. The integration test asserts this byte-for-byte for both the `gd` and `imagick` adapters across `jpg`/`webp`/`avif` (see [Tests](#tests)). Pass `--no-decode-once` to decode per rendition everywhere (the previous, more conservative behaviour).

> `--parallel` runs each worker as a separate `bin/console` process over a slice of the media, aggregating progress into a single bar. It has no effect on `--dry-run` (which does no work).

Tests
-----

[](#tests)

```
composer install
composer test          # or: vendor/bin/phpunit
```

- **`tests/Unit`** — pure command logic (translated filename building, option parsing, shard partitioning, worker-summary parsing). No database or container needed.
- **`tests/Integration`** — proves the default decode-once strategy produces **byte-identical** output to Sulu's `ImagineImageConverter` across multiple formats and extensions (`jpg`/`webp`/`avif`), for every locally available Imagine adapter (`gd` and/or `imagick`). Skipped automatically if neither extension is installed.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance94

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

14

Last Release

26d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a3bea97975bdeddcfa5b76c222740e703e4ff5f9bbf5f6d5d75e8827e0a48ac?d=identicon)[alengodev](/maintainers/alengodev)

---

Top Contributors

[![hual7](https://avatars.githubusercontent.com/u/89628357?v=4)](https://github.com/hual7 "hual7 (18 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alengo-sulu-translated-media-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/alengo-sulu-translated-media-bundle/health.svg)](https://phpackages.com/packages/alengo-sulu-translated-media-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M204](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M577](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
