add image package.

This commit is contained in:
Edward Yang 2022-07-12 17:31:27 +08:00
parent 4ae9035673
commit 32a840a4a2
6 changed files with 128 additions and 7 deletions

View File

@ -13,7 +13,7 @@ class FileManagerController extends Controller
$page = (int)$request->get('page');
$data = (new FileManagerService)->getFiles($baseFolder, $page);
if ($request->ajax()) {
if ($request->expectsJson()) {
return $data;
}
return view('admin::pages.filemanager.index', $data);

View File

@ -97,7 +97,7 @@ class FileManagerService
return [
'path' => $filePath,
'name' => $baseName,
'url' => image_resize("catalog{$filePath}", 100, 100),
'url' => image_resize("catalog{$filePath}"),
'selected' => false,
];
}

View File

@ -1,13 +1,12 @@
<?php
use Beike\Models\AdminUser;
use Beike\Models\Customer;
use Beike\Models\Setting;
use Illuminate\Support\Facades\Route;
use Beike\Models\Customer;
use Beike\Models\AdminUser;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Route;
use Illuminate\Contracts\Auth\Authenticatable;
/**
* 获取后台设置到 settings 表的值
*

View File

@ -0,0 +1,31 @@
<?php
/**
* ImageService.php
*
* @copyright 2022 opencart.cn - All Rights Reserved
* @link http://www.guangdawangluo.com
* @author Edward Yang <yangjin@opencart.cn>
* @created 2022-07-12 17:30:20
* @modified 2022-07-12 17:30:20
*/
class ImageService
{
public function resize($image, $width = 100, $height = 100)
{
$imagePath = public_path($image);
$img = \Intervention\Image\Facades\Image::make($imagePath);
$img->resize($width, $height);
// $img->insert('public/watermark.png');
$baseName = basename($imagePath);
$imageInfo = explode('.', $image);
$imageName = $imageInfo[0];
$imageExt = $imageInfo[1];
$newImagePath = public_path("cache/{$imageName}-{$width}x{$height}.{$imageExt}");
\Illuminate\Support\Facades\File::ensureDirectoryExists($newImagePath, 0755, true);
$img->save($newImagePath);
dd($newImagePath);
}
}

View File

@ -9,6 +9,7 @@
"ext-json": "*",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"intervention/image": "^2.7",
"laravel/framework": "^8.65",
"laravel/tinker": "^2.5",
"stripe/stripe-php": "^8.8"

92
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c52e9e1b5b722611e7a5c8632e2611df",
"content-hash": "6a2ff68409a1cfa702ce085441932b73",
"packages": [
{
"name": "asm89/stack-cors",
@ -1035,6 +1035,96 @@
],
"time": "2021-10-06T17:43:30+00:00"
},
{
"name": "intervention/image",
"version": "2.7.2",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "04be355f8d6734c826045d02a1079ad658322dad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/04be355f8d6734c826045d02a1079ad658322dad",
"reference": "04be355f8d6734c826045d02a1079ad658322dad",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1 || ^2.0",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7 || ^7.5.15"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https://intervention.io/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"support": {
"issues": "https://github.com/Intervention/image/issues",
"source": "https://github.com/Intervention/image/tree/2.7.2"
},
"funding": [
{
"url": "https://paypal.me/interventionio",
"type": "custom"
},
{
"url": "https://github.com/Intervention",
"type": "github"
}
],
"time": "2022-05-21T17:30:32+00:00"
},
{
"name": "laravel/framework",
"version": "v8.78.0",