Search by

swoopde / contao-imagemask-bundle

schreck78

Image+SVG Mask content element via RSCE for Contao 4.13, 5.x & 6.x

Package info

github.com/swoopDe/contao-imagemask-bundle

Homepage

Issues

Type:contao-bundle

pkg:composer/swoopde/contao-imagemask-bundle

Statistics

Installs: 138

Dependents: 0

Suggesters: 0

Stars: 1

v2.0.2 2026-12-02 13:37 UTC

This package is auto-updated.

Last update: 2026-12-02 13:41:33 UTC


README

Contao Cookiebar

Contao ImageMask Bundle

🇬🇧 English (below) | 🇩🇪 Deutsch (above)

RSCE-Inhaltselement für Bild-Masken mit SVG

(Compatible with Contao 4.13, 5.x and 6.x)

Image Mask Result
Screenshot Screenshot Screenshot

🇩🇪 Deutsch

Beschreibung

Dieses Bundle stellt ein RockSolid Custom Element (RSCE) bereit,
mit dem du ein Bild mit einer SVG-Maske kombinieren kannst.
Die Maske kann mit dem Bild synchron skaliert werden (z. B. „100 % Breite – automatische Höhe“).
Unterstützt Contao 4.13, Contao 5.x und Contao 6.x (Twig-Templates).

Funktionen

  • RSCE-Inhaltselement „Image with Mask | Bild mit Maske“
  • Auswahl von Bild und Maske (SVG, PNG, WebP) oder einem mitgelieferten Brush
  • Option: Maske an Bildskalierung koppeln
  • Brush normal oder invertiert (Bild überall sichtbar, die Brush-Form wird ausgeschnitten)
  • Aspect-Ratio / min-height / Custom CSS-Klassen
  • Automatische Sprachumschaltung (DE/EN)
  • Kompatibel mit Contao 4, 5 und 6 (Twig & HTML5)

Brushes

Das Bundle bringt fertige Masken („Brushes“) mit. Sie werden im Backend als Kacheln mit Vorschau angezeigt und können direkt ausgewählt werden.

  • Eine eigene Maske (SVG) hat immer Vorrang vor dem Brush.
  • Mindestens eins von beiden muss gesetzt sein.
  • Masken und Brushes: SVG, PNG oder WebP. PNG und WebP brauchen Transparenz – deckende Pixel zeigen das Bild, transparente schneiden es weg, halbtransparente maskieren teilweise (weiche Pinselkanten). Raster-Brushes ausreichend groß anlegen (ca. 2000–2500 px), sonst werden die Kanten bei großen Bildern unscharf.
  • Ablage: src/Resources/public/brushes/{größe}/{farbe}/{name}-{farbe}-{größe}.webp, z. B. 1024/black/brush-01-black-1024.webp. Mitgeliefert sind 40 Brushes in 768, 1024, 1280 und 2560 px. Die 2560-px-Variante ist für große Elemente und hochauflösende Bildschirme (z. B. 4K) gedacht, damit die Pinselkanten scharf bleiben; bei neu gewählten Brushes ist die größte Variante vorausgewählt. Die Farbe des Brushes spielt für die Maske keine Rolle, nur die Transparenz.
  • Im Backend ist die Auswahl zugeklappt: Die Kopfzeile „Mitgelieferten Brush auswählen“ zeigt die aktuelle Auswahl, ein Klick öffnet die Kacheln. Pro Brush gibt es eine Kachel, gruppiert nach Farbe. Unter jeder Kachel werden die Größe (Standard: die größte) und der Modus „Normal“ oder „Invertiert“ gewählt. Gespeichert wird der Pfad der gewählten Variante.
  • Reihenfolge und Namen (DE/EN) optional in brushes.json, Schlüssel ohne Größe:
{ "black/brush-01": { "de": "Schwarz 01", "en": "Black 01" },
  "black/brush-21": { "de": "Schwarz 21", "en": "Black 21", "newRow": true } }

"newRow": true lässt den Brush im Backend in einer neuen Zeile beginnen.

  • Contao stellt den Ordner bei composer install/update automatisch unter public/bundles/contaoimagemask/brushes/ bereit.

Optional CSS

.ce_imagemask .ce-imagemask__inner {
  width: 100%;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
}

Logging

  • Logging aktivieren: config/packages/monolog.yaml
  • Logging-Kanal: imagemask
  • Logging-Level: debug
  • Logging-Datei: var/logs/imagemask.log
#contao 5 
$logger = \System::getContainer()->get('monolog.logger.imagemask');
$logger->debug('Debug info', ['data' => $myVar]);

#contao 4
\System::log('My debug message', __METHOD__, TL_GENERAL);

⚙️ Installation

composer require swoopDe/contao-imagemask-bundle

🇬🇧 English

🧩 Description

This bundle provides a RockSolid Custom Element (RSCE) to combine an image with an SVG mask. The mask can be synchronized with the image scaling (e.g. “100% width — automatic height”). Supports Contao 4.13, Contao 5.x and Contao 6.x (Twig templates).

  • Features
  • RSCE content element “Image Mask”
  • Select image and mask (SVG, PNG, WebP) or a bundled brush
  • Option: sync mask scale/position with the image
  • Brush normal or inverted (image visible everywhere, the brush shape is cut out)
  • Aspect ratio / min-height / custom CSS classes
  • Automatic language switching (DE/EN)
  • Works with Contao 4, 5 and 6 (Twig & HTML5)

Brushes

The bundle ships with ready-made masks ("brushes"). They are shown in the backend as preview tiles and can be selected directly.

  • A custom mask (SVG) always takes precedence over the brush.
  • At least one of them must be set.
  • Masks and brushes: SVG, PNG or WebP. PNG and WebP need transparency – opaque pixels show the image, transparent ones cut it away, semi-transparent ones mask partially (soft brush edges). Make raster brushes large enough (approx. 2000–2500 px), otherwise edges get blurry on large images.
  • Storage: src/Resources/public/brushes/{size}/{color}/{name}-{color}-{size}.webp, e.g. 1024/black/brush-01-black-1024.webp. 40 brushes are bundled in 768, 1024, 1280 and 2560 px. The 2560 px variant is meant for large elements and high-resolution screens (e.g. 4K) so the brush edges stay sharp; for newly selected brushes the largest variant is preselected. The brush color does not matter for the mask, only its transparency.
  • In the backend the picker is collapsed: the header "Select bundled brush" shows the current selection, a click opens the tiles. The backend shows one tile per brush, grouped by color, with a size select (default: largest) and a mode select (normal or inverted) below each tile. The path of the selected variant is stored.
  • Order and names (DE/EN) can optionally be set in brushes.json (see above).
  • Contao publishes the folder automatically under public/bundles/contaoimagemask/brushes/ on composer install/update.

Optional CSS

.ce_imagemask .ce-imagemask__inner {
  width: 100%;
  display: block;
  background-repeat: no-repeat;
  background-position: center;
}

⚙️ Installation

composer require swoopDe/contao-imagemask-bundle

📝 Lizenz / License

Swoop Attribution License 1.0 (ab Version 2.0.0) – siehe LICENSE.md.

Die Nutzung ist kostenlos, auch gewerblich. Auf öffentlich erreichbaren Websites ist eine Namensnennung mit Link auf die Projektseite Pflicht, z. B. im Impressum. Fertige Textbausteine stehen in ATTRIBUTION.md. Entwicklungs-, Test- und interne Systeme sind ausgenommen.

Free to use, including commercially. Publicly accessible websites must show an attribution with a link to the project page, e.g. in the legal notice. Ready-made snippets are in ATTRIBUTION.md. Development, test and internal systems are exempt.

Versionen vor 2.0.0 bleiben unter der MIT-Lizenz. / Versions prior to 2.0.0 remain licensed under MIT.

Abhängigkeiten wie Contao (LGPL-3.0-or-later) und RockSolid Custom Elements (MIT) unterliegen ihren eigenen Lizenzen. / Dependencies such as Contao (LGPL-3.0-or-later) and RockSolid Custom Elements (MIT) are governed by their own licenses.

🧡 Credits

Developed with love for the Contao community. Tested with Contao 4.13 LTS, 5.6 and 6.0.