All Projects → reliqarts → Laravel Guided Image

reliqarts / Laravel Guided Image

Licence: mit
Simplified and ready image manipulation for Laravel through intervention image.

Projects that are alternatives of or similar to Laravel Guided Image

Laravel Imageup
Auto Image & file upload, resize and crop for Laravel eloquent model using Intervention image
Stars: ✭ 646 (+1918.75%)
Mutual labels:  laravel, trait, upload
Has Parameters
A trait that allows you to pass arguments to Laravel middleware in a more PHP'ish way.
Stars: ✭ 149 (+365.63%)
Mutual labels:  hacktoberfest, laravel, trait
Laravel Medialibrary
Associate files with Eloquent models
Stars: ✭ 4,743 (+14721.88%)
Mutual labels:  hacktoberfest, laravel, upload
Orm
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen
Stars: ✭ 712 (+2125%)
Mutual labels:  hacktoberfest, laravel
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+1850%)
Mutual labels:  hacktoberfest, laravel
Laravel Boilerplate
Laravel Boilerplate / Starter Kit with Gentelella Admin Theme
Stars: ✭ 704 (+2100%)
Mutual labels:  hacktoberfest, laravel
Laravel Ban
Laravel Ban simplify blocking and banning Eloquent models.
Stars: ✭ 572 (+1687.5%)
Mutual labels:  laravel, trait
Laravel Adminpanel
A Laravel Admin Panel (Laravel Version : 6.0)
Stars: ✭ 774 (+2318.75%)
Mutual labels:  hacktoberfest, laravel
Platform
A modular multilingual CMS built with Laravel 5.
Stars: ✭ 719 (+2146.88%)
Mutual labels:  hacktoberfest, laravel
Transit
Easy file uploading and downloading for Laravel 5.
Stars: ✭ 5 (-84.37%)
Mutual labels:  laravel, upload
Lvartisan
Laravel artisan command for creating view.
Stars: ✭ 18 (-43.75%)
Mutual labels:  laravel, view
Core
Simple forum software for building great communities.
Stars: ✭ 5,372 (+16687.5%)
Mutual labels:  hacktoberfest, laravel
Laravel Stager
Laravel Stager State Machine, Its purpose is to add state machine functionality to models
Stars: ✭ 16 (-50%)
Mutual labels:  laravel, trait
Tenancy
Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups.
Stars: ✭ 916 (+2762.5%)
Mutual labels:  hacktoberfest, laravel
Artisan View
👀 Manage your views in Laravel projects through artisan
Stars: ✭ 708 (+2112.5%)
Mutual labels:  hacktoberfest, laravel
Befriended
Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.
Stars: ✭ 596 (+1762.5%)
Mutual labels:  laravel, trait
Laravel View Models
View models in Laravel
Stars: ✭ 722 (+2156.25%)
Mutual labels:  laravel, view
Laravel Sri
Subresource Integrity hash generator for laravel
Stars: ✭ 23 (-28.12%)
Mutual labels:  hacktoberfest, laravel
Laravel Mediable
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.
Stars: ✭ 541 (+1590.63%)
Mutual labels:  hacktoberfest, laravel
Blade
🔪 A standalone version of Laravel's Blade templating engine for use outside of Laravel.
Stars: ✭ 542 (+1593.75%)
Mutual labels:  laravel, view

Laravel Guided Image

Guided Image is an image utility package for Laravel based on Intervention Image.

Built For Laravel Build Status (all) Scrutinizer Codecov License Latest Stable Version Latest Unstable Version

 

Guided Image for Laravel

Key Features

  • On-the-fly image resizing
  • On-the-fly thumbnail generation
  • Image uploading
  • Smart image reuse; mitigating against double uploads and space resource waste.

Guided Image can be integrated seamlessly with your existing image model.

Guided Routes

The package provides routes for generating resized/cropped/dummy images.

  • Routes are configurable you you may set any middleware and prefix you want.
  • Generated images are cached to disk to avoid regenerating frequently accessed images and reduce overhead.

Image file reuse

For situations where different instances of models use the same image.

  • The package provides a safe removal feature which allows images to be detached and only deleted from disk if not being used elsewhere.
  • An overridable method is used to determine when an image should be considered safe to delete.

Installation & Usage

Installation

Install via composer; in console:

composer require reliqarts/laravel-guided-image

or require in composer.json:

{
    "require": {
        "reliqarts/laravel-guided-image": "^3.0"
    }
}

then run composer update in your terminal to pull it in.

Finally, publish package resources and configuration:

php artisan vendor:publish --provider="ReliqArts\GuidedImage\ServiceProvider"

You may opt to publish only configuration by using the guidedimage-config tag:

php artisan vendor:publish --provider="ReliqArts\GuidedImage\ServiceProvider" --tag="guidedimage-config"

Setup

Set the desired environment variables so the package knows your image model, controller(s), etc.

Example environment config:

GUIDED_IMAGE_MODEL=Image
GUIDED_IMAGE_CONTROLLER=ImageController
GUIDED_IMAGE_ROUTE_PREFIX=image
GUIDED_IMAGE_SKIM_DIR=images

These variables, and more are explained within the config file.

And... it's ready! 👌

Usage

To use Guided Image you must do just that from your Image model. 😏

Implement the ReliqArts\GuidedImage\Contract\GuidedImage contract and use the ReliqArts\GuidedImage\Concern\Guided trait, e.g:

use Illuminate\Database\Eloquent\Model;
use ReliqArts\GuidedImage\Concern\Guided;
use ReliqArts\GuidedImage\Contract\GuidedImage;

class Image extends Model implements GuidedImage
{
    use Guided;

    // ... properties and methods
}

See example here.

Implement the ReliqArts\GuidedImage\Contract\ImageGuide contract and use the ReliqArts\GuidedImage\Concern\Guide trait from your ImageController, e.g:

use ReliqArts\GuidedImage\Contract\ImageGuide;
use ReliqArts\GuidedImage\Concern\Guide;

class ImageController extends Controller implements ImageGuide
{
    use Guide;
}

See example here.

Features

Safely Remove Image (dissociate & conditionally delete the image)

An guided image instance is removed by calling the remove method. e.g:

$oldImage->remove($force);

$force is optional and is false by default.

Link Generation

You may retrieve guided links to resized or cropped images like so:

// resized image:
$linkToImage = $image->routeResized([
    '550',      // width
    '_',        // height, 'null' is OK 
    '_',        // keep aspect ratio? true by default, 'null' is OK
    '_',        // allow upsize? false by default, 'null' is OK
]);

// thumbnail:
$linkToImage = $image->routeThumbnail([
    'crop',     // method: crop|fit
    '550',      // width
    '_',        // height
]);

NB: In the above example _ resolves to null.

Have a look at the GuidedImage contract for more info on model functions.

For more info on controller functions see the ImageGuide contract.

Routes

Your actually routes will depend heavily on your custom configuration. Here is an example of what the routes may look like:

|| GET|HEAD | image/.dum//{width}-{height}/{color?}/{fill?}           | image.dummy           | App\Http\Controllers\[email protected]       | web |
|| GET|HEAD | image/.res/{image}//{width}-{height}/{aspect?}/{upSize?}| image.resize          | App\Http\Controllers\[email protected]     | web |
|| GET|HEAD | image/.tmb/{image}//m.{method}/{width}-{height}         | image.thumb           | App\Http\Controllers\[email protected]       | web |
|| GET|HEAD | image/empty-cache                                       | image.empty-cache     | App\Http\Controllers\[email protected]  | web |

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].