Download the PHP package drh2so4/thumbnail without Composer
On this page you can find all versions of the php package drh2so4/thumbnail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download drh2so4/thumbnail
More information about drh2so4/thumbnail
Files in drh2so4/thumbnail
Package thumbnail
Short Description Package for making thumbnails instantly.
License MIT
Informations about the package thumbnail
Laravel Thumbnail Generator
Package for uploading the image and saving that image along with it's thumbnail.
What does it do ?
- Uploads Image
- Make its thumbnail i.e low quality, resized version of its parent image
Why use thumbnails ?
The small file size of thumbnails makes it possible for website designers to offer visitors a lot of content immediately without increasing the loading time of the page. Also why use full glory of that image if you just have to crunched it up to tiny space... Use thumbnail.
Installation
Run Composer Require Command
Use thumbnail trait to your model
This model consists of following methods :-
- makeThumbnail
- thumbnail
- uploadImage
- hasThumbnail
- thumbnailCount
- imageDetail
- hardDelete
Usages
Package utilizes it's trait method, let us guide you to use that
makeThumbnail
This method is responsible for actually uploading the image and making its thumbnail.
Same can go with update method.
thumbnail
Well, we created our thumbnail but how to use it, let me guide through that When we uploaded image with name suppose "batman". Image is upload with name batman-current_time_instant i.e (batman-1521549.jpg).
What about thumbnail... well thumbnail uses it's parent image name followed by -size i.e batman-1521549-medium-jpg, batman-1521549-small.jpg
How to make thumbnail ?
There are the options you can have for making thumbnails :-
- Default Option
- Universal Custom Thumbnails
- Specfic Custom Thumbnails
Default Option
you can just call the following and the packages will handle the rest
Note : if the attribute dedicated for storing image is named 'image' you don't have to pass image attribute name jusr use \$image->makeThumbnail();
Universal Custom Thumbnails
here you should mention the thumbnails that you want to be applied on every case. when you publish thumbnail.php config file you will find 'thumbnails' property where you can mention your custom thumbnails
Note: This will override default option
Specfic Custom Thumbnails
Suppose you have applied Universal Custom Thumbnails but need to have changes for specific image field then you can pass array of custom requirements :
How about multiple image uploads
If you are performing multiple image upload at once pass image key to thumbnail array. here \$img is one of the image in chunk of images passed
How to use thumbnail ?
Just call as following
if you are using custom thumbnail configured from config file just call as follows
Notice that parameter of function thumbnail is string same as value given for "thumbnail-name" in config file.
Thumbnail's image property is predefined but if you wish to change that publish it's config file thumbnail.php
Image Property
You can obtaing the detail image property by using method imageDetail($image,$size)
What Image Property/Detail Gives
Default Thumbnail Image Properties
Property | Return Type | Description | Example |
---|---|---|---|
image | string | Image path stored in DB | \$image->imageDetail('image')->image |
name | string | Image Stored Name (without extension) | \$image->imageDetail('image')->name |
fullname | string | Image Stored Name (with extension) | \$image->imageDetail('image')->fullname |
extension | string | Image Extension Name | \$image->imageDetail('image')->extension |
path | string | Image Storage Path | \$image->imageDetail('image')->path |
directory | string | Image Stored Directory | \$image->imageDetail('image')->directory |
location | string | Image Full Location Path | \$image->imageDetail('image')->location |
property | array | Image Property array | \$image->imageDetail('image')->property |
Image Property array (\$image->imageDetail('image')->property)
Property | Return Type | Description | Example |
---|---|---|---|
real_name | string | Image Real Name (without timestamp and size label) | \$image->imageDetail('image')->property->name |
size | integer | Image Storage Size | \$image->imageDetail('image')->property->fullname |
directory | string | Image Stored Directory | \$image->imageDetail('image')->property->directory |
location | string | Image Full Location Path | \$image->imageDetail('image')->property->location |
has_thumbnail | boolean | Image's Thumbnail Check | \$image->imageDetail('image')->property->has_thumbnail |
thumbnail_count | integer | Image Thumbnail Count | \$image->imageDetail('image')->property->thumbnail_count |
thumbnails | array | Return all thumbnail Detail | \$image->imageDetail('image')->property->thumbnails |
Image Thumbnail Property | Property | Return Type | Description |
---|---|---|---|
image | string | Thumbnail Name | |
real_name | string | Thumbnail Real Name (without timestamp and size label) | |
size | integer | Thumbnail Storage Size | |
created_date | Carbon | Thumbnail Created Date | |
path | string | Thumbnail Storage Path | |
directory | string | Thumbnail Stored Directory | |
location | string | Thumbnail Full Location Path |
Check if image has thumbnail
Obtain Image Thumbnail Count
Hard Delete Image with Thumbnails
Hard Delete Image with Thumbnails adn its parent
Upload Only Umage
Our config file looks like follows :-
Feel free to change the values
Default Thumbnail Image Properties
Thumbnail | Width | Height | Quality |
---|---|---|---|
Uploaded Image | 1000 | 800 | 80 |
Medium Thumbnail | 800 | 600 | 60 |
Small Thumbnail | 400 | 300 | 30 |
Todos
- Error Handling
- Image Caching
- Maintainabilty
Package Used
License
MIT
DOCTYPE NEPAL || DR.H2SO4