linhchan/imgur

此包最新版本(dev-master)没有可用的许可证信息。

这是一个演示版本

安装: 5

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

语言:HTML

dev-master 2019-06-10 10:46 UTC

This package is auto-updated.

Last update: 2024-09-10 21:55:46 UTC


README

CircleCI codecov.io Latest Stable Version Latest Unstable Version Total Downloads License

注意,这是一个演示版本

安装

composer require linhchan/imgur
In config/app.php

Add service provider to your app.php [Providers]
...
Linhchan\Imgur\ImgurServiceProvider::class,

Binding class using Facade in laravel app.php [Aliases]
...
'Imgur' => Linhchan\Imgur\Facades\Imgur::class,
Publish config 
$ php artisan vendor:publish
Add your Imgur client id and client secret to you .env config
IMGUR_CLIENT_ID=
IMGUR_CLIENT_SECRET=

文档

您可以在 文档 中获取更多信息

测试

$ phpunit

用法

如果您需要上传一张图片并将其转换为链接以便于存储或访问

use Linhchan\Imgur\Facades\Imgur;

class ImgurController extends Controller
{
    public function index()
    {
        // Test Imgur Facade
        $uploadFile = 'https://w3schools.org.cn/w3css/img_lights.jpg';
        $image = Imgur::upload($uploadFile);

        // Get imgur image link.
       $image->link(); //"https://i.imgur.com/XN9m1nW.jpg"

        // Get imgur image file type.
        $image->type(); //"image/jpeg"

        // Get imgur image width.
        $image->width(); //480

        // Get imgur image height.
        $image->height(); //640

        // Or you can get usual data.
        return $image->usual();

        //[
        //  'link' => "https://i.imgur.com/XN9m1nW.jpg",
        //  'filesize' => 43180,
        //  'type' => "image/jpeg",
        //  'width' => 480,
        //  'height' => 640,
        //]
    }
}