novius/laravel-media-toolbox 问题修复 & 功能扩展

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

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

novius/laravel-media-toolbox

Composer 安装命令:

composer require novius/laravel-media-toolbox

包简介

This packages helps you optimize pictures on-the-fly

README 文档

README

Travis Packagist Release Licence

Optimize your pictures on-the-fly! 🛫

Requirements

Laravel >= 8.0

NOTE: These instructions are for Laravel >= 8.0. If you are using prior version, please see the previous version's docs.

Installation

composer require novius/laravel-media-toolbox

Then, you must publish and run the migrations to create the language_lines table:

php artisan vendor:publish --provider="Novius\MediaToolbox\MediaToolboxServiceProvider" --tag="migrations"
php artisan migrate

Then add this to config/app.php:

// in 'aliases' => [ ... ]
'Medt' => Novius\MediaToolbox\Support\MediaToolbox::class,

Use

In a view:

<!-- This will change the height proportionaly, in order to keep the aspect -->
<img src="{{ Medt::asset('images/hello.png')->width(150) }}">

<!-- It works as well with external pictures. Setting the ratio will force
     previously defined dimensions and change the remaining ones, here the height -->
<img src="{{ Medt::asset('https://example.com/images/logo.png')->width(500)->ratio(16/9) }}">

<!-- fit('cover') is the default behavior. You can just omit it -->
<img src="{{ Medt::asset($user->getPicture())->size(140, 200)->fit('cover') }}">
<img src="{{ Medt::asset($user->getPicture())->size([140, 200])->fit('stretch') }}">

<!-- This will output a jpg with 75% quality.
     Lower number makes smaller files. Minimum is 1, max is 100 -->
<img src="{{ Medt::asset('images/something.gif')->quality(75) }}">

SEO Friendly

You can specify a name for your filename (value will be converted to slug) :

Usage in a view:

<img src="{{ Medt::asset('images/hello.png')->quality(90)->name('my image') }}">

Configure

Publish the config file:

php artisan vendor:publish --provider="Novius\MediaToolbox\MediaToolboxServiceProvider"

Edit config/mediatoolbox.php.

Clearing the cache manually

php artisan cache:clear

Purge expired medias

In your app/Console/Kernel.php file, you should register a daily job to purge expired medias :

protected function schedule(Schedule $schedule)
{
    $schedule->command('media-toolbox:purge-expired')
        ->daily();
}

By default, media is stale considered after 1 week. You can override this value in configuration file with `expire key.

Lint

Run php-cs with:

composer run-script lint

Contributing

Contributions are welcome! Leave an issue on Github, or create a Pull Request.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2018-08-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固