Skip to content

It will gradually optimize all images in a given folder (e.g. assets folder) via shortpixel api.

Notifications You must be signed in to change notification settings

arillo/silverstripe-shortpixel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Silverstripe Shortpixel

Latest Stable Version Total Downloads License

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 . 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="<YOUR_SHORTPIXEL_API_KEY>"

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: <ABSOLUTE_PATH_TO_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.

About

It will gradually optimize all images in a given folder (e.g. assets folder) via shortpixel api.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages