linhchan/imgur

There is no license information available for the latest version (dev-master) of this package.

This is a demo

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

This package is auto-updated.

Last update: 2024-04-10 20:59:50 UTC


README

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

Note that this is a demo version

Installation

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=

Documentation

You can get for more information at Documentation

Test

$ phpunit

Usage

If you need to upload an image and convert it to a link for storing or accessing easily

use Linhchan\Imgur\Facades\Imgur;

class ImgurController extends Controller
{
    public function index()
    {
        // Test Imgur Facade
        $uploadFile = 'https://www.w3schools.com/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,
        //]
    }
}