ellie1337/laravel-images 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ellie1337/laravel-images

最新稳定版本:1.0.2

Composer 安装命令:

composer require ellie1337/laravel-images

包简介

Manage & resize images easily

README 文档

README

This is a QoL wrapper around intervention/image, with the intent on removing the cognitive load to create well sized images.

Installation

composer require ellie1337/laravel-images
php artisan vendor:publish --tag=laravel-images
php artisan storage:link

How it works

Super simple way for blades, etc

<img src="{{ \webp('my-file.jpg', height: 100) }}" />

Usage:

  • webp, png, jpg, avif functions are exposed
  • Accepts as many or as few params as you'd like: width, height, background, quality, placeholder
  • Maintains aspect ratio, injects background into any additional space
  • Returns a full URL to pipe into a blade

Elsewhere (or if you prefer a nicer API)

use Ellie1337\LaravelImages\Services\Image;

/** @var Image $image */
$image = app(Image::class);

$image->path('my-file.jpg')
    ->width(100)
    ->height(100)
    ->type('webp')
    ->url(); // equivalent to \webp('my-file.jpg', width: 100, height: 100);

Cleaning up your images

Sometimes you delete an image, and that's okay!

use Ellie1337\LaravelImages\Services\Image;

/** @var Image $image */
$image = app(Image::class);

$image->delete('my-file.jpg', deleteSource: true);

The delete function will delete all cached variants of the source image. If deleteSource is true, it will also delete the source image itself.

Hooking into the lifecycle

If you assign an image in a model, eg as a user avatar, you can hook into the deleting method to make life much easier!

use Ellie1337\LaravelImages\Services\Image;

// model
protected static function booted() {
    static::deleting(function ($model) {
        if ($model->avatar) {
            app(Image::class)
                ->delete($model->avatar, deleteSource: true);
        }
    })
}

License

This project is licensed under the MIT License.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固