https://github.com/arillo/silverstripe-shortpixel
It will gradually optimize all images in a given folder (e.g. assets folder) via shortpixel api.
https://github.com/arillo/silverstripe-shortpixel
Last synced: 9 months ago
JSON representation
It will gradually optimize all images in a given folder (e.g. assets folder) via shortpixel api.
- Host: GitHub
- URL: https://github.com/arillo/silverstripe-shortpixel
- Owner: arillo
- Created: 2019-07-31T12:57:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-26T15:33:28.000Z (almost 7 years ago)
- Last Synced: 2025-06-01T20:54:36.902Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Silverstripe Shortpixel
[](https://packagist.org/packages/arillo/silverstripe-shortpixel)
[](https://packagist.org/packages/arillo/silverstripe-shortpixel)
[](https://packagist.org/packages/arillo/silverstripe-shortpixel)
**CAUTION: work in progress, do not use in production!**
It will gradually optimze all images in a given folder (e.g. assets folder) via [shortpixel api](https://shortpixel.com) .
Purposed to run via cronjob.
Adds a Shortpixel-Tab to your `SiteConfig`, where you can switch off task execution and where you can find api status information.
## Setup
Get a shortpixel api key and set it in your `.env`:
```
SP_APIKEY=""
```
Configuration file (e.g. shortpixel.yml):
```
---
Name: myshortpixelconfig
After:
- '#shortpixelconfig'
---
Arillo\Shortpixel\Shortpixel:
# all option in: ShortPixel\ShortPixel::$options
options:
lossy: 0 # 1 - lossy, 2 - glossy, 0 - lossless
Arillo\Shortpixel\Tasks\FolderTask:
exclude_folders:
- '.protected' # omit .protected, default nothing
# configure ShortPixel
shortpixel_settings:
max_allowed_files_per_call: 5 # default: 10
client_max_body_size: 20 # default: 48
wait: 300 # default: 500
# you can turn off auto file re-hashing, if you want to.
# plays nice with beforeShortPixelCall and afterShortPixelCall hooks, to create your own recovery strategy
use_simple_image_recovering: false # default true
# optionally you can set the root folder
root_folder: # default ASSETS_PATH
```
Setup an cronjob to execute the task:
```
*/1 * * * * php vendor/silverstripe/framework/cli-script.php dev/tasks/ShortpixelFolderTask
```
You might need to play around with cronjob timing and `shortpixel_settings` to avoid multiple overlapping executions.
Find more information about options & settings in `Arillo\Shortpixel\Tasks\FolderTask`.