Skip to content

Commit

Permalink
Add support L11 (#8)
Browse files Browse the repository at this point in the history
* add spatie Image V3

* Change render Croppa method to new crop V3 Spatie Image

* check Laravel 11

* fix carbon on run test

* fix on file error, remove them in board

* Fix styling

---------

Co-authored-by: webplusmultimedia <webplusmultimedia@users.noreply.github.com>
  • Loading branch information
webplusmultimedia and webplusmultimedia authored Apr 17, 2024
1 parent 9667987 commit 40208ff
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.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.1'
php-version: '8.2'
coverage: none

- name: Install composer dependencies
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.2, 8.1]
laravel: [10.*]
php: [8.3,8.2, 8.1]
laravel: [10.*,11.*]
stability: [prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
carbon: ^2.63
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
exclude:
- laravel: 11.*
php: 8.1

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

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"illuminate/contracts": "^10.0",
"spatie/image": "^2.2",
"illuminate/contracts": "^10.0|^11.0",
"spatie/image": "^2.2|^3.0",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/collision": "^7.9|^8.0",
"larastan/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
Expand Down
3 changes: 1 addition & 2 deletions config/gallery-json-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

// config for WebplusMultimedia\GalleryJsonMedia
use Spatie\Image\Manipulations;

return [
'disk' => 'public',
Expand All @@ -13,7 +12,7 @@
'signing_key' => 'app.key',
'driver' => 'imagick', // gd or imagick
'quality' => 80,
'thumbnails-crop-method' => Manipulations::CROP_CENTER,
'thumbnails-crop-method' => null,
'thumbnails-saved-format' => null, // Manipulations::FORMAT_PNG / following formats are supported: FORMAT_JPG, FORMAT_PJPG, FORMAT_PNG, FORMAT_GIF, FORMAT_WEBP and FORMAT_TIFF

],
Expand Down
4 changes: 2 additions & 2 deletions resources/dist/components/gallery-json-media.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions resources/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,17 @@ export function galleryFileUpload(
/**@type {HTMLElement} */
const wrapper = this.$refs.galleryImages
const stopUploading = function(component) {
let rest = component.uploadFiles.filter(f => f.is_success === false).length
let rest = component.uploadFiles.filter(f => f.is_success === false).length,
numberErrors = component.uploadFiles.filter(f => f.error === true).length

if (rest === 0) {
if ((rest - numberErrors) === 0) {
component.dispatchFormEvent('form-processing-finished')
if(numberErrors) {
// Removed thumbnails with no upload
component.uploadFiles = component.uploadFiles
.filter(file => !file.error)
.map(file =>{ file.error = false; return file })
}
component.startUpload = false
}
}
Expand All @@ -91,7 +98,6 @@ export function galleryFileUpload(
stopUploading(this)
}
const error = (fileKey) => {
//delete this.uploadFiles[fileKey]
this.uploadFiles[fileKey].progress = 0
this.uploadFiles[fileKey].error = true
stopUploading(this)
Expand Down
33 changes: 11 additions & 22 deletions src/JsonMedia/ImageManipulation/Croppa.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Spatie\Image\Exceptions\InvalidImageDriver;
use Spatie\Image\Exceptions\InvalidManipulation;
use Spatie\Image\Image;
use Spatie\Image\Manipulations;

final class Croppa
{
Expand All @@ -34,28 +33,18 @@ public function url(): string
*/
public function render(): void
{
$image = Image::load($this->filesystem->path($this->filePath))
->useImageDriver(config('gallery-json-media.images.driver'));

$manipulations = new Manipulations();
$manipulations->quality(config('gallery-json-media.images.quality'));

if ($this->width and $this->height) {
$manipulations->crop(
cropMethod: config('gallery-json-media.images.thumbnails-crop-method'),
width: $this->width,
height: $this->height
);
} else {
if ($this->width) {
$manipulations->width($this->width);
}
if ($this->height) {
$manipulations->height($this->height);
}
$image = Image::useImageDriver(config('gallery-json-media.images.driver'))
->load($this->filesystem->path($this->filePath))
->quality(config('gallery-json-media.images.quality'));

if ($this->width) {
$image->width($this->width);
}
if ($this->height) {
$image->height($this->height);
}
$image->manipulate($manipulations)
->save($this->filesystem->path($this->getPathNameForThumbs()));

$image->save($this->filesystem->path($this->getPathNameForThumbs()));
}

protected function getPathNameForThumbs(): string
Expand Down

0 comments on commit 40208ff

Please sign in to comment.