定制 digbang/files 二次开发

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

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

digbang/files

最新稳定版本:v2.0.0

Composer 安装命令:

composer require digbang/files

包简介

File handling library

README 文档

README

This library helps with the handling of files and images. The files are stored physically using Laravel's filesystem configuration; and logically into a table in the database.

Usage

Mappings

$builder->manyToOne(File::class, 'propertyName'); $builder->belongsTo(ImageFile::class, 'imagePropertyName');

Image Handling

Each ImageFile has an optional parent image (the original one). This allows to have a tree of curated images attached to the original.

For example:

public function __construct(FileRepository $repository, ImageCurator $curator)
{
    $this->repository = $repository;
    $this->curator = $curator;
}

public function curateImage(ImageFile $originalImage): ImageFile
{
    if (! ($curatedImage = $originalImage->getCurated('SOME_IDENTIFICATION_KEY'))) {
        $originalImage->setContentGetter(function () use ($originalImage) {
            return $this->repository->getContents($originalImage->getId());
        });
    
        $curation = $this->curator
            ->resize(WIDTH, HEIGHT)
            ->interlace()
            ->optimize() //not yet implemented
            ->buildCuration();
    
        $curatedImage = $originalImage->curate('SOME_IDENTIFICATION_KEY', $curation);
        $curatedImage->setContentGetter(function () use ($curatedImage) {
            return $this->repository->getContents($curatedImage->getId());
        });
    
        $this->repository->persist($curatedImage);
    }
    
    return $curatedImage;
}

The imageCurator can be extended or replaced. Also, you can implement another curator alongside the pre-existing one and use both at the same time.

The only requirement is that the curator should return an array of callbacks that the Curation object can apply to the image.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-09