Giter VIP home page Giter VIP logo

nilsvannoort / nova-advanced-image-field Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ctessier/nova-advanced-image-field

0.0 0.0 0.0 702 KB

๐ŸŒ„ ๐Ÿ“ A Laravel Nova advanced image field with cropping and resizing using Cropper.js and Intervention Image

Home Page: https://novapackages.com/packages/ctessier/nova-advanced-image-field

License: MIT License

JavaScript 2.59% PHP 33.81% Vue 63.61%

nova-advanced-image-field's Introduction

Nova Advanced Image Field

StyleCI Latest Version on Packagist Total Downloads License

An advanced image field for Nova allowing you to upload, crop and resize images

Need support for Laravel Nova 4?

This package uses Cropper.js with vue-cropperjs on the client and Intervention Image on the server.

screenshot of the advanced image field

Requirements

In order to work, this package requires the following components:

  • Laravel & Nova (2 or 3)
  • Fileinfo Extension

And one of the following libraries:

  • GD Library >=2.0 (default)
  • Imagick PHP extension >=6.5.7

See Intervention requirements for more details.

Getting started

Install the package into a Laravel application with Nova using Composer:

composer require ctessier/nova-advanced-image-field

If you want to use Imagick as the default image processing library, follow the Intervention documentation for Laravel. This will provide you with a new configuration file where you can specify the driver you want.

Code examples

AdvancedImage extends from Image so you can use any methods that Image implements. See the documentation here.

// Show a cropbox with a fixed ratio
AdvancedImage::make('Photo')->croppable(16/9),

// Resize the image to a max width
AdvancedImage::make('Photo')->resize(1920),

// Override the image processing driver for this field only
AdvancedImage::make('Photo')->driver('imagick'),

To serve the image as an avatar / cover art search results, use the AdvancedAvatar class:

AdvancedAvatar::make('Avatar')->croppable(),

API

driver(string $driver)

Override the default driver to be used by Intervention for the image manipulation.

AdvancedImage::make('Photo')->driver('imagick'),

croppable([float $ratio])

Specify if the underlying image should be croppable.

If a numeric value is given as a first parameter, it will be used to define a fixed aspect ratio for the crop box.

AdvancedImage::make('Photo')->croppable(),
AdvancedImage::make('Photo')->croppable(16/9),

resize(int $width = null[, int $height = null])

Specify the size (width and height) the image should be resized to.

AdvancedImage::make('Photo')->resize(1920),
AdvancedImage::make('Photo')->resize(600, 400),
AdvancedImage::make('Photo')->resize(null, 300),

Note: this method uses Intervention Image resize() with the upsize and aspect ratio constraints.

autoOrientate()

Specify if the underlying image should be orientated.

Rotate the image to the orientation specified in Exif data, if any.

AdvancedImage::make('Photo')->autoOrientate(),

Note: PHP must be compiled in with --enable-exif to use this method. Windows users must also have the mbstring extension enabled. See the Intervention Image documentation for more details.

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.