ahmed-bhs / sulu-media-sync-bundle
Partage les medias entre les locales d'une page Sulu : une image choisie sur la langue de reference est recopiee sur les autres, les metadonnees restant traduisibles.
Package info
github.com/ahmed-bhs/SuluMediaSyncBundle
Type:symfony-bundle
pkg:composer/ahmed-bhs/sulu-media-sync-bundle
Requires
- php: ^8.2
- doctrine/dbal: ^3.6 | ^4.0
- doctrine/doctrine-bundle: ^2.10
- doctrine/orm: ^2.15 | ^3.0
- sulu/sulu: ^3.0
- symfony/config: ^6.2 | ^7.0
- symfony/console: ^6.2 | ^7.0
- symfony/dependency-injection: ^6.2 | ^7.0
- symfony/event-dispatcher: ^6.2 | ^7.0
- symfony/framework-bundle: ^6.2 | ^7.0
- symfony/http-foundation: ^6.2 | ^7.0
- symfony/http-kernel: ^6.2 | ^7.0
- symfony/messenger: ^6.2 | ^7.0
- symfony/routing: ^6.2 | ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.5 | ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-08 09:06:18 UTC
README
Share images across the locales of a Sulu page.
An image picked on the reference locale is copied to the other locales on save. Texts stay translated, and media metadata (title, description, alt text) stays translatable locale by locale in the media library.
Sharing is switched on and off from the admin, without a deploy.
Why
Sulu stores a media selection in the page content, so one row per locale. Picking an image in French does not touch English: that is deliberate, an image may have to differ per market.
When it does not, and editing always happens in the same language, copying by hand becomes a chore. This bundle automates it while keeping the escape hatch: turn sharing off the day a locale needs its own image.
Installation
composer require ahmed-bhs/sulu-media-sync-bundle
The bundle is registered by Flex. Otherwise, in config/bundles.php:
Ahmed\SuluMediaSyncBundle\SuluMediaSyncBundle::class => ['all' => true],
Then create the settings table:
php bin/console doctrine:schema:update --force
Configuration
Everything is optional. Defaults:
# config/packages/sulu_media_sync.yaml sulu_media_sync: enabled: true source_locale: 'fr' template_directories: - '%kernel.project_dir%/config/templates/pages'
enabled and source_locale are only the initial values: once a setting is
changed in the admin, the database wins.
Usage
From the admin
Settings > Shared media across locales: a checkbox to turn sharing on, and
a field for the reference locale.
On save
Once enabled, saving a page in the reference locale copies its media properties to the other locales.
Only drafts are written. A locale already online is then republished, so the site shows the new image; a locale still in draft stays that way, so text nobody approved is never published.
Catching up existing pages
The subscriber only handles pages saved after it was switched on. For the rest:
php bin/console media-sync:propagate --dry-run # show what would change php bin/console media-sync:propagate # update the drafts php bin/console media-sync:propagate --publish # also put back online
Options: --source=en to use a reference locale other than the stored setting.
What is propagated
Top-level properties typed media_selection, single_media_selection and
image_map.
What is not:
- Media nested inside a block. They belong to their block, and copying the whole block would mix translated text with the image.
- Texts, SEO, excerpt. Nothing but media properties is touched.
- Media metadata. It lives on the media, not on the page, and stays translatable.
Alt texts
The bundle shares the selection, not the rendering. If your templates
hardcode alt texts instead of reading media.title, translating metadata in
the media library will have no effect on the site. That is independent of
image sharing.
Limitations
- Pages only: articles and snippets are not covered.
- Media nested inside blocks are not propagated.
- The service API may still change before 1.0.
Tests
composer install vendor/bin/phpunit
License
MIT