This addon provides a simple way to zip your assets on the fly
Install the addon using Composer.
composer require aerni/zipper
You may also publish the config of the addon.
php please vendor:publish --tag=zipper-config
The following config will be published to config/zipper.php
.
return [
/*
|--------------------------------------------------------------------------
| Save To Disk
|--------------------------------------------------------------------------
|
| Set this to 'true' to save the created zips to disk.
|
*/
'save' => false,
/*
|--------------------------------------------------------------------------
| Filesystem Disk
|--------------------------------------------------------------------------
|
| Choose the disk you want to use when saving a zip.
|
*/
'disk' => 'public',
];
To create a zip of your assets, you have to call the zip
tag followed by the variable
containing your assets.
Somewhere in your content files:
images:
- sega-genesis.jpg
- snes.jpg
Somehwere in your views:
{{ zip:images }}
The tag returns the URL to the route that handles creating the zip. The zip will be streamed and won't be saved to disk. You can change this behaviour in the config.
By default, the filename of the zip will be the current timestamp. You can also customize the filename. The example below binds the filename of the zip to the title of the current page.
{{ zip:images :filename='title' }}