srhinow/contao-page-images-bundle

Set one or more images central per page in Contao CMS. This is a Fork from 'Ruudt/contao-page_images' and updated for >=Contao 5.3 and >=PHP 8.3

Maintainers

Package info

gitlab.com/srhinow/contao-page-images-bundle

Issues

Type:contao-module

pkg:composer/srhinow/contao-page-images-bundle

Statistics

Installs: 1 815

Dependents: 1

Suggesters: 0

Stars: 0

3.0.0 2026-04-25 20:52 UTC

This package is auto-updated.

Last update: 2026-04-25 18:52:36 UTC


README

Assign one or more images to pages in Contao CMS. Images are inherited by subpages unless explicitly disabled.

This is a fork of Ruudt/contao-page_images, rewritten for Contao 5.3+ and PHP 8.3+.

Requirements

  • PHP ^8.3
  • Contao ^5.3

Installation

composer require srhinow/contao-page-images-bundle

After installation run php bin/console contao:migrate to set up the database tables.

Architecture

Database tables

TablePurpose
tl_pageimagesImage categories (each defines a "slot" in the layout, with a default image and size settings)
tl_pageimages_itemsAssignments of images to specific pages
tl_pageimages_pagesJunction table — stores which pages each item applies to

Backend module

Located under Content → Page images in the Contao back end.

  1. Create a category (tl_pageimages) — give it a name and configure the default image size and a fallback image.
  2. Add items (tl_pageimages_items) — select images and assign them to one or more pages. Optionally add a text overlay and control subpage inheritance.

Frontend module

Module type: Page images (page_images).

FieldDescription
Page image categoryWhich category to display
Page image templateTemplate to use for rendering (pageimages_*)
Number of images1 = first, 0 = all, random = random single, N = first N

Image resolution / inheritance

When the module renders for a page, PageImagesService walks up the page tree:

  1. Look for an item assigned directly to the current page.
  2. If none, walk up to the parent page (unless an item has Prevent inheritance enabled).
  3. If nothing is found anywhere in the tree, use the category's default image.

Templates

TemplateDescription
mod_page_images.html.twigOuter module wrapper — renders pageimage if has_pageimage is true
pageimages_default.html.twigRenders the images with optional text overlay; uses contao_figure()

Custom templates must be placed in templates/ and must start with pageimages_.

Hooks

The compilePageImages hook fires after images are resolved:

$GLOBALS['TL_HOOKS']['compilePageImages'][] = [MyClass::class, 'myMethod'];

Signature: myMethod(Template $template, array $pageImages, ModuleModel $model): void

User permissions

Two permission keys are registered for back-end users and groups:

KeyDescription
pageimages_categoriesWhich categories the user may access
pageimages_categoriespOperations allowed: create, delete

Running tests

Tests must be run from the main Contao installation:

vendor/bin/phpunit -c vendor/srhinow/contao-page-images-bundle/phpunit.xml.dist