Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.3]
laravel: [11.*]
php: [8.4, 8.5]
laravel: [12.*]
stability: [prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 12.*
testbench: 10.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.3]
laravel: [11.*]
php: [8.4, 8.5]
laravel: [12.*]
stability: [prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 12.*
testbench: 10.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4, 8.5
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.2, 8.3 ]
laravel: [ 11.* ]
php: [ 8.4, 8.5 ]
laravel: [ 12.* ]
stability: [ prefer-lowest, prefer-stable ]
include:
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 11.*
php: 8.1
- laravel: 12.*
testbench: 10.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,42 @@

You can search for this addon in the `Tools > Addons` section of the Statamic control panel and click **install**, or run the following command from your project root:

``` bash
```bash
composer require justbetter/statamic-image-optimize
```

## Requirements
The addon makes use of batches to optimize the images.
Because of this you need an active Database connection that contains the `job_batches` table.

The addon makes use of **Laravel Batches** to optimize images.
Because of this you need an active database connection that contains the `job_batches` table.
You can generate this table by running the following commands:

```
```bash
php artisan queue:batches-table
php artisan migrate
```

If your queue connection is not `sync`, make sure a queue worker is running.

## Config

### Publish

```
```bash
php artisan vendor:publish --provider="JustBetter\ImageOptimize\ServiceProvider"
```

### Settings

It's possible to change to default resize width and height by overriding the config file and changing the parameters within.

You can change the default resize width/height and queue settings in `config/image-optimize.php` (or via env vars like `IMAGE_OPTIMIZE_WIDTH`, `IMAGE_OPTIMIZE_HEIGHT`, `IMAGE_OPTIMIZE_QUEUE_CONNECTION`, `IMAGE_OPTIMIZE_QUEUE_NAME`).

## Commands
```

```bash
php artisan justbetter:optimize:images
```

By running this command you can recursively optimize all the images in the assets folder.
By running this command you can optimize images in the Statamic asset library.

### Options

Expand All @@ -56,8 +59,7 @@ this will show a progress bar containing the amount of jobs left in the batch.

- After an image is uploaded an event will trigger to optimize the image.
The event optimizes the images and resizes it to a specified size, this is being controlled by the config file.

- By using the resize images command you can recursively optimize all the images in the assets folder.

- By using the optimize images command you can optimize images in the asset library.
- Added an action in the CP Asset overview that allows you to select assets and trigger the optimize job manually.
- Added an CP page to manually optimize all images, triggering this will show a progress bar containing the remaining images.
- Added a CP page to optimize remaining images or force-optimize all images, showing batch progress while it runs.

22 changes: 12 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
}
],
"require": {
"php": "^8.2|^8.3",
"php": "^8.4|^8.5",
"ext-fileinfo": "*",
"statamic/cms": "^5.0",
"laravel/framework": "^11.0 || ^12.0",
"league/glide": "^2.3"
"intervention/image": "^3.0",
"statamic/cms": "^6.0",
"laravel/framework": "^12.0",
"league/glide": "^3.0"
},
"require-dev": {
"laravel/pint": "^1.7",
"larastan/larastan": "^2.5",
"phpstan/phpstan-mockery": "^1.1",
"phpunit/phpunit": "^10.1 || ^11.5",
"orchestra/testbench": "^8.0|^9.0|^10.0",
"pestphp/pest": "^2.0"
"larastan/larastan": "^3.4",
"phpstan/phpstan-mockery": "^2.0",
"phpunit/phpunit": "^11.5",
"orchestra/testbench": "^10.3",
"pestphp/pest": "^3.7"
},
"autoload": {
"psr-4": {
Expand All @@ -41,8 +42,9 @@
},
"scripts": {
"test": "phpunit",
"analyse": "phpstan",
"analyse": "phpstan --memory-limit=1G",
"style": "pint --test",
"coverage": "XDEBUG_MODE=coverage php vendor/bin/pest --coverage --min=100",
"quality": [
"@test",
"@analyse",
Expand Down
8 changes: 4 additions & 4 deletions config/image-optimize.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

return [
// Set the default resize width in pixels
'default_resize_width' => env('IMAGE_OPTIMIZE_WIDTH', 1600),
// Set the max resize width in pixels
'max_resize_width' => env('IMAGE_OPTIMIZE_WIDTH', 2560),

// Set the default resize height in pixels
'default_resize_height' => env('IMAGE_OPTIMIZE_HEIGHT', 1600),
// Set the max resize height in pixels
'max_resize_height' => env('IMAGE_OPTIMIZE_HEIGHT', 2560),

// Set the default queue name
'default_queue_name' => env('IMAGE_OPTIMIZE_QUEUE_NAME', 'default'),
Expand Down
3 changes: 1 addition & 2 deletions dist/js/statamic-image-optimize.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/js/statamic-image-optimize.js.LICENSE.txt

This file was deleted.

16 changes: 7 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
"private": true,
"description": "Image optimization after upload",
"scripts": {
"development": "mix",
"watch": "mix watch",
"production": "mix --production"
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"author": "JustBetter",
"dependencies": {
"vue": "^2.6.12",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.12"
"vue": "^3.5.0"
},
"devDependencies": {
"cross-env": "^7.0.3",
"laravel-mix": "^6.0.49",
"postcss": "^8.4.21"
"@statamic/cms": "file:./vendor/statamic/cms/resources/dist-package",
"postcss": "^8.4.21",
"vite": "^6.0.0"
}
}
Loading
Loading