Download the PHP package presprog/kirby-auto-file-templates without Composer
On this page you can find all versions of the php package presprog/kirby-auto-file-templates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download presprog/kirby-auto-file-templates
More information about presprog/kirby-auto-file-templates
Files in presprog/kirby-auto-file-templates
Package kirby-auto-file-templates
Short Description Automatically assign file templates on upload based on the file type
License MIT
Informations about the package kirby-auto-file-templates
Automatically assign templates to your uploaded files
⚡ Ready for Kirby 4!
This plugin automatically assigns file templates to your uploaded files, based on the respective file type. This way it does not matter, which file type you upload from which field or section – the template assigned will always be the same. This is especially handy, when you use a single files section per page, that stores all the different file types used on the page.
[!IMPORTANT] Requires at least Kirby 4.0 and PHP 8.2
🚀 How to use
Set up your configuration (see next section) first. The plugin will then run after each uploaded file (file.create:after
hook) and assign the configured template automatically.
If you add the plugin to an existing project, you can run the auto-templates
command from the CLI. It will iterate over every file in every page and assign the template according to the configuration:
By default, existing template assignments will not be touched. To change that, run the command with --force/-f
or set the forceOverwrite
option globally in your config.php
(see below).
⚙️ Config
The plugin works in an opt-in manner: It does nothing except you tell it to.
With autoAssign = true
, each file type will get the identically named file blueprint assigned as template:
File type | File blueprint |
---|---|
audio | site/blueprints/files/audio |
archive | site/blueprints/files/archive |
code | site/blueprints/files/code |
image | site/blueprints/files/image |
video | site/blueprints/files/video |
your-type | site/blueprints/files/your-type |
* The Kirby core file types archive
, audio
, document
, image
and video
and your custom file type extensions are supported out-of-the-box.
💻 How to install
Install this plugin via Composer (recommended):
Or download the ZIP file from GitHub and unpack it to site/plugins/kirby-auto-file-templates
Or as Git submodule
✅ To do
- [ ] Add multi-language support
📄 License
MIT License Copyright © 2024 Present Progressive
Made by Present Progressive for the Kirby community.