定制 johntout/laravel-image-sizes 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

johntout/laravel-image-sizes

最新稳定版本:1.4.2

Composer 安装命令:

composer require johntout/laravel-image-sizes

包简介

Laravel Image Sizes Package

关键字:

README 文档

README

A Laravel package to store images in different sizes. There are also options for various video provider urls.

This package was created for a personal project and I publish it in case anyone has the same needs. Cheers :)

Requirements

PHP 8+
Laravel 9+

Installation

Step 1: Install johntout/laravel-image-sizes with composer:

composer require johntout/laravel-image-sizes

The package is using intervention/image package for image manipulation. Before using laravel-image-sizes package, make sure to checkout the intervention/image docs for laravel integration.

Step 2: Publish config file

php artisan vendor:publish --tag="laravel-image-sizes-config"

If you want to use Twitch video provider to embed player to your app, add this to your .env file.

APP_DOMAIN=yourdomain.com

Usage

Use properties or Laravel Attributes to set in which disk and directory you want to create the images. The package uses Laravel's filesystem. The different sizes of the images are defined in the config file.

class User extends Model 
{
    use JohnTout\LaravelImageSizes\HasMedia;
    
    public string filesystem_disk = 'avatars';
    
    public string image_field = 'avatar';
    
    // OR
    
    /**
     * @return Attribute
     */
    public function filesystemDisk(): Attribute
    {
        return Attribute::make(
            get: fn () => 'avatars'
        );
    }

    /**
     * @return Attribute
     */
    public function imageField(): Attribute
    {
        return Attribute::make(
            get: fn () => 'avatar'
        );
    }
}
$user = User::query()->find(1);
$user->saveImage($request->file('image'));

You can get the image url using this:

$user->imageUrl(size: 'originalImage');

Notes

The package is using v2 intervention/image package. For more information about image manipulation options, see intervention/image docs.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固