Giter VIP home page Giter VIP logo

laravel-image-resize's Introduction

Image Resize Helper for Laravel 5.x

Dynamically resize an image and returns the URL using Intervention and Storage

Latest Stable Version Latest Unstable Version

Require

  • Laravel 5+
  • Intervention Image ^2.4

Supported Filesystem Drivers

  • Local
  • S3
  • Oss (Aliyun Cloud Storage)

Installation

This package can be installed through Composer.

composer require maximumadvertising/laravel-image-resize

For Laravel 5.4 and lower, you'll have to register the service provider and alias manually.

Add to service providers

Mxmm\ImageResize\ImageResizeServiceProvider::class,

And alias

'ImageResize' => Mxmm\ImageResize\Facade::class,	

Publish config and assets (Optional)

php artisan vendor:publish --provider="Mxmm\ImageResize\ImageResizeServiceProvider"

Usage

Accepted parameters:

/**
 * @param string|null $path
 * @param int|null $width
 * @param int|null $height
 * @param string $action
 * @return string
 */
public static function url(string $path = null, int $width = null, int $height = null, string $action = 'fit'): string

In HTML:

<img src="{{ ImageResize::url('originalDir/filename.jpg', width, height, [action]) }}" />

Fit (resize & crop) an image to 200x200px

<img src="{{ ImageResize::url('originalDir/filename.jpg', 200, 200, 'fit') }}" />

Resize an image to 200x200px

<img src="{{ ImageResize::url('originalDir/filename.jpg', 200, 200, 'resize') }}" />

Fit (resize & crop) an image to 200px width, with auto height

<img src="{{ ImageResize::url('originalDir/filename.jpg', 200, null, 'fit') }}" />

sample output

<img src="https://localhost/thumbs/originalDir/fit/200x200/filename.jpg" />

Tests

Run tests with:

vendor/bin/phpunit

laravel-image-resize's People

Contributors

jonasva avatar markpadilla avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.