This package can be installed through Composer.
composer require LaraX/thumbnail
When using Laravel, if you are using a version pre v5.5 you will need to include the Service Provider manually:
// app/config/app.php
'providers' => [
// ...
'LaraX\Screenshots\LaraXProvider'
];
Setup your API keys:
// config/larax.php
'THUMBNAIL' => [
'PREFIX' => 'thumbnail_',
'SIZE' => [
'width' => 267,
'height' => null
]
];
and in your .env file:
# THUMBNAIL
GENERATE_THUMBNAIL=TRUE
Here is a sample call to generate a LaraXThumbnail screenshot URL:
use LaraX\Thumbnail\LaraXThumbnail;
$LaraXThumbnail = new LaraXThumbnail();
$thumbnailUrl = $LaraXThumbnail->makeThumbnail(storage_path('app/public/'. $folder .$newFileName), $folder, 'public', 'thumbnail_', 240);
// Generate a screenshot by loading the Urlbox URL in an img tag:
echo '<img src="' . $thumbnailUrl . '" alt="Test thumbnail generated">'
If you're using Laravel and have set up the service provider, you can use the Facade provided:
use LaraX\Thumbnail\LaraXThumbnail;
// Create the thumbnail URL
$LaraXThumbnail = new LaraXThumbnail();
$thumbnailUrl = $laraXThumbnail->makeThumbnail(storage_path('app/public/'. $folder .$newFileName), $folder, 'public', 'thumbnail_', 240);
You can now use the result ($thumbnailUrl
) by placing it inside an <img/>
tag as the src
parameter.
We are open to pull requests.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Generating thumbnail in laravel basing intervention Image
The MIT License (MIT).