|
9 | 9 |
|
10 | 10 | Laravel-Imgur is super easy upload image to imgur package. |
11 | 11 |
|
12 | | -## Requirement |
13 | | -#### laravel 5 or later |
14 | | - |
15 | | -## Installation |
16 | | - |
17 | | -Install via composer |
18 | | -``` bash |
19 | | -$ composer require yish/imgur |
20 | | -``` |
21 | | - |
22 | | -If you use 5.5 or later, you don’t need to add provider into app.php, just use discovery autoloading. |
23 | | -``` php |
24 | | -Yish\Imgur\UploadServiceProvider::class, |
25 | | -``` |
26 | | - |
27 | | -### Facade binding |
28 | | -app.php |
29 | | -``` php |
30 | | -'Imgur' => Yish\Imgur\Facades\Upload::class, |
31 | | -``` |
32 | | - |
33 | | -### Publish config |
34 | | -``` bash |
35 | | -$ php artisan vendor:publish |
36 | | -``` |
37 | | - |
38 | | -## Usage |
39 | | -``` php |
40 | | -Imgur::upload($args); |
41 | | -``` |
42 | | - |
43 | | -Arguments can be a image link or file, for example, you can pass a https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/Apple_logo_black.svg/1200px-Apple_logo_black.svg.png or use file upload *MUST* instance of `Illuminate\Http\UploadedFile` . |
44 | | - |
45 | | -### Customize |
46 | | -If you want to customize your headers or form params, you can do belong: |
47 | | - |
48 | | -``` php |
49 | | -Imgur::setHeaders([ |
50 | | - 'headers' => [ |
51 | | - 'authorization' => 'Client-ID ' . env('IMGUR_CLIENT_ID'), |
52 | | - 'content-type' => 'application/x-www-form-urlencoded', |
53 | | - ] |
54 | | - ])->setFormParams([ |
55 | | - 'form_params' => [ |
56 | | - 'image' => $image, |
57 | | - ] |
58 | | - ])->upload($image); |
59 | | -``` |
60 | | - |
61 | | -## Quick Starter |
62 | | -You can use methods to get what you want informations. |
63 | | - |
64 | | -``` php |
65 | | -$image = Imgur::upload($file); |
66 | | - |
67 | | -// Get imgur image link. |
68 | | -$image->link(); //"https://i.imgur.com/XN9m1nW.jpg" |
69 | | - |
70 | | -// Get imgur image file size. |
71 | | -$image->fileszie(); //43180 |
72 | | - |
73 | | -// Get imgur image file type. |
74 | | -$image->type(); //"image/jpeg" |
75 | | - |
76 | | -// Get imgur image width. |
77 | | -$image->width(); //480 |
78 | | - |
79 | | -// Get imgur image height. |
80 | | -$image->height(); //640 |
81 | | - |
82 | | -// Or you can get usual data. |
83 | | -$image->usual(); |
84 | | - |
85 | | -//[ |
86 | | -// 'link' => "https://i.imgur.com/XN9m1nW.jpg", |
87 | | -// 'filesize' => 43180, |
88 | | -// 'type' => "image/jpeg", |
89 | | -// 'width' => 480, |
90 | | -// 'height' => 640, |
91 | | -//] |
92 | | -``` |
93 | | - |
94 | | -Sometimes, you need get more image size, you can call `size` to get more thumbnails. |
95 | | -``` php |
96 | | - |
97 | | -$image = Imgur::upload($file); |
98 | | - |
99 | | -// Support: https://api.imgur.com/models/image |
100 | | - |
101 | | -// Get small square. |
102 | | -$small_square = Imgur::size($image->link(), 's'); |
103 | | - |
104 | | -// Get big square thumbbnail. |
105 | | -$small_square = Imgur::size($image->link(), 'b'); |
106 | | - |
107 | | -// Get small small thumbbnail. |
108 | | -$small_square = Imgur::size($image->link(), 't'); |
109 | | - |
110 | | -// Get small medium thumbbnail. |
111 | | -$small_square = Imgur::size($image->link(), 'm'); |
112 | | - |
113 | | -// Get small large thumbbnail. |
114 | | -$small_square = Imgur::size($image->link(), 'l'); |
115 | | - |
116 | | -// Get small huge thumbbnail. |
117 | | -$small_square = Imgur::size($image->link(), 'h'); |
118 | | -``` |
| 12 | +https://packages.yish.dev/packages/laravel-imgur.html |
0 commit comments