Skip to content

Allow custom collage layouts from private folder#1428

Open
paaaaaaul0101 wants to merge 8 commits intoPhotoboothProject:devfrom
paaaaaaul0101:pr/collage-layouts
Open

Allow custom collage layouts from private folder#1428
paaaaaaul0101 wants to merge 8 commits intoPhotoboothProject:devfrom
paaaaaaul0101:pr/collage-layouts

Conversation

@paaaaaaul0101
Copy link
Contributor

@paaaaaaul0101 paaaaaaul0101 commented Jan 20, 2026

Prerequisites checklist

What is the purpose of this pull request? (put an "x" next to an item)

  • Documentation update
  • Bug fix
  • New feature
  • Other, please explain:

What changes did you make? (Give an overview)

  • Replaced the hardcoded collage layout list with dynamically loaded layouts defined as JSON files.
  • Added a new API getCollageLayouts.php that scans
    private/collage/layouts and its landscape / portrait subdirectories and returns available layouts as { id, label }.
  • Updated the backend to treat layout IDs as free strings instead of fixed enums.
  • Implemented a deterministic layout resolution and fallback order in Collage.php:
    1. private/collage/layouts/<orientation>
    2. private/collage/layouts
    3. legacy paths in private/collage/*
    4. template/collage/*
  • Invalid or faulty private layout JSONs are ignored:
    • If a template layout with the same name exists, the template remains active.
    • If no template exists, the faulty private layout is not shown.
  • Updated the admin GUI to load the layout list fully dynamically via the new API (no hardcoded layout array).
  • The start screen layout selection now relies solely on string IDs stored in layouts_enabled; display names are taken from the name field in the layout JSON.

Tests:

  • npm run build
  • npm run eslint
  • Verified dynamic discovery of layouts from all supported directories
  • Confirmed new layouts appear in the admin UI immediately after adding a JSON file (after F5)
  • Verified layout priority and fallback behavior across private, legacy, and template paths

Is there anything you'd like reviewers to focus on?

  • Layout resolution priority/fallback in src/Collage.php
  • Layout listing order/override behavior in api/getCollageLayouts.php
  • Creation of the path not yet completed: private/collage/layouts/landscape and private/collage/layouts/portrait

AI used to create this Pull Request?

I used AI selectively in the code, for minor suggestions, alternatives or for understanding.
The idea, concept and logic behind the changes are my own.

@andi34
Copy link
Contributor

andi34 commented Jan 20, 2026

Hey and thanks for your contributions!
Could you short describe your own parts of code adjustments not the AI?

@paaaaaaul0101
Copy link
Contributor Author

Hi Andi :)
Please excuse my laziness.

Initial situation:
I am reaching a clear limit with the existing collage layouts. The available layout slots are not sufficient because I need many custom collages. Repurposing the current layouts for this quickly makes the system confusing.

Therefore, I want to move away from a fixed layout list defined in code. The goal is to be able to use any number of custom collage layouts without having to make code changes for each new layout.

Goal:
I want to be able to use custom collage layouts as JSON files. These should be loaded from a fixed directory and automatically displayed in the GUI. New layouts should become available simply by adding a JSON file, with a clean fallback to existing template layouts.

Implementation:
I have created a new API, getCollageLayouts.php. This API reads all existing collage layout JSONs from the directory private/collage/layouts as well as from the subdirectories landscape and portrait (directories still need to be created) and returns the available layouts as a structured list with id and label.

The backend has been adjusted so that layout IDs are no longer treated as fixed enums but are accepted as free strings. This means the system is no longer bound to a predefined list of layouts.

When loading a layout in Collage.php, a fixed priority applies:
First, private/collage/layouts/<orientation> is checked, then private/collage/layouts.
If no valid layout is found there, the fallback uses the previous paths in private/collage/* (whether private makes sense here could be reconsidered) and template/collage/*.

Private layout JSONs that are invalid or faulty are ignored.
If a template layout with the same name exists, it remains active.
If no template layout exists, the faulty private layout is not displayed.

The admin GUI loads the available layout list fully dynamically via the new API. There is no longer a layout array hardcoded in the code, so new layouts automatically appear in the interface as soon as the corresponding JSON file is added.

The layout selection on the start screen is based exclusively on the string IDs stored in layouts_enabled. The display name is taken from the name value in the corresponding layout JSON.

@paaaaaaul0101
Copy link
Contributor Author

Fix collage selection preview for dynamic layouts

  • I removed hardcoded CollageLayoutEnum checks in template/components/collageSelection.php so the collage preview works with dynamic/custom layout IDs.
  • I made 2x text duplication shifts layout-driven (not fixed 50% offsets) in src/Collage.php to align text under custom column widths.

Improve 2x layout text and cut-line positioning

  • I enabled cut lines for all 2x* layouts and positioned them using actual layout gaps to keep the line centered between columns/rows.

@andi34 andi34 force-pushed the pr/collage-layouts branch from 5c07ec6 to 5ce05fe Compare January 26, 2026 12:57
@andi34 andi34 requested a review from reloxx13 January 26, 2026 13:08
@reloxx13
Copy link
Collaborator

reloxx13 commented Jan 27, 2026

I don’t get the collage svg previews in the admin selection, only on the start page. Apart from that, it looks fine. Thank you.
PS: and i fixed a warning on startpage

Copy link
Collaborator

@reloxx13 reloxx13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge paaaaaaul0101#1

@paaaaaaul0101
Copy link
Contributor Author

Admin: add collage layout previews

  • Added SVG preview output to getCollageLayouts.php (orientation‑aware with fallback).
  • Render previews in the admin layout selection grid and pass ?orientation= to the API.
  • Admin selection now shows the same previews as the start page.

@paaaaaaul0101
Copy link
Contributor Author

@andi34 Ready for deployment to dev? :)

@andi34
Copy link
Contributor

andi34 commented Feb 4, 2026

@paaaaaaul0101 i'll try to test the PR until end of the week and merge if everything works fine

@andi34 andi34 force-pushed the pr/collage-layouts branch from 4200292 to 37fa803 Compare February 4, 2026 05:09
@andi34
Copy link
Contributor

andi34 commented Feb 4, 2026

Rebased

@paaaaaaul0101
Copy link
Contributor Author

Hi @andi34, I wanted to ask if there are any updates or if something is still needed from my side. :)

@andi34
Copy link
Contributor

andi34 commented Feb 16, 2026

Hey! Not sure yet, only have testes quickly and my private/collage.json was ignored. Currently private life has priority and Photobooth development not possible next week(s).
Not sure if @reloxx13 has tested this a little more and can give green light and merge.

@reloxx13
Copy link
Collaborator

Hey,
im not so familiar with the collage feature. I'll try to test it later and merge it. But feel free to ping me again if I forget.

@paaaaaaul0101
Copy link
Contributor Author

Hi @andi34, totally understandable.
Thanks for the quick test anyway. Please don’t stress about it. Take the time you need, and I hope everything on your side is going well.
Whenever it fits, just jump back in and we’ll sync up.
All the best!

Hi @reloxx13, here’s how the scan works right now:

Admin list (what gets shown):

  • private/collage/layouts/<orientation>/
  • private/collage/layouts/
  • template/collage/<orientation>/
  • template/collage/

Legacy fallback (loaded only if the layout ID is explicitly selected):

  • private/collage/<orientation>/
  • private/collage/
  • private/

So a file like collage.json is not shown in the admin list, it’s only considered if the selected layout ID is exactly collage.

This separation is intentional so custom layouts live in one predictable folder and the admin list stays clean.

Do you want me to extend the admin list scan to include private/ (or private/collage/) as well, or should we keep it strict to private/collage/layouts/?

@reloxx13
Copy link
Collaborator

Hey,
An important test is the migration, setup the current version and than update to ur code and check if all config and collage files are migrated

@paaaaaaul0101
Copy link
Contributor Author

Follow-up for migration safety:

  • Ensure these directories are created automatically if missing:
    • private/collage/layouts
    • private/collage/layouts/landscape
    • private/collage/layouts/portrait
  • Extend admin layout scan to include legacy paths:
    • private/collage/<orientation>/
    • private/collage/
  • Include private/collage.json in admin layout discovery as a targeted legacy file (without scanning all of /private).

Handling of private/collage.json:

  • It is treated as a legacy layout source.
  • It is now included in the admin layout list scan as a single explicit file.
  • Runtime loading behavior in Collage::getCollageConfigPath() remains unchanged and still supports legacy fallback resolution.

Why:

On existing installations, custom layouts may still be stored in legacy private collage paths (private/collage/...) or as private/collage.json.
This keeps updates backward-compatible and prevents missing custom layouts after migration.

@paaaaaaul0101
Copy link
Contributor Author

Hi @reloxx13, quick update:

I added a migration-focused follow-up and tested it on my productive system.

What was added:

  • Auto-create missing directories:

    • private/collage/layouts
    • private/collage/layouts/landscape
    • private/collage/layouts/portrait
  • Extend admin scan to include legacy paths:

    • private/collage/<orientation>/
    • private/collage/
  • Include private/collage.json as a targeted legacy source (without scanning all of /private).

Production test result:

  • private/collage.json is recognized
  • missing layout folders are created automatically
  • custom JSON layouts are detected correctly

Could you please do one final migration re-check?
If everything looks good on your side, feel free to merge.

@andi34 andi34 added the collage label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants