Giter Site home page Giter Site logo

pandahisham / image-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joselfonseca/image-manager

0.0 2.0 0.0 848 KB

image manager for Laravel apps

Home Page: https://josefonseca.me

License: MIT License

JavaScript 19.64% CSS 1.10% PHP 79.26%

image-manager's Introduction

Laravel image Manager package

Build Status Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight

A little Image Manager to use in forms and API's.

This is the stable version for Laravel 4.2.*, compatibility with laravel 5 is being scheduled.

Requirements

1. Jquery
2. Bootstrap 3
3. Laravel 4.2.*

The package will insert colorbox JS and Plupload JS, make sure you import colorbox.css to your templates.

Installation

In your composer.json file add:

"joselfonseca/image-manager" : "1.0.*"

Run composer update

Add the service provider

'Joselfonseca\ImageManager\ImageManagerServiceProvider'

Then run the migration php artisan migrate --package=joselfonseca/image-manager

Then public the assets.

php artisan asset:publish joselfonseca/image-manager

Finally reference the assets in the layout

<link href="{{asset('packages/joselfonseca/image-manager/css/imagemanager.css')}}" rel="stylesheet">
<link href="{{asset('packages/joselfonseca/image-manager/vendors/colorbox/colorbox.css')}}" rel="stylesheet">
<script src="{{asset('packages/joselfonseca/image-manager/js/imageManager.min.js')}}"></script>

Usage

Make sure you have a field in your database to store the image id and inside your form add

<label for='titulo'>Imagen del Post</label>
{{ImageManager::getField(['text' => 'Select the File', 'class' => 'btn btn-primary', 'field_name' => 'your_field_name', 'default' => '12'])}}

Parameters

    - text: the text for the button
    - class: the class to apply to the button
    - field_name: the field name for the image selected, this creates a hidden input with the field_name to get the id of the image selected when you post the form
    - default: the id for the image to be selected by default

How to render an image?

To render an image you can add to the src the route action('showthumb', $id)

// this will show a thumb
<img src="{{action('showthumb', $default)}}" />
// this the full image
<img src="{{action('media', $default)}}" />
// this the full image resized by with
<img src="{{action('media', ['id' => $default, 'width' => 300])}}" />
// this the full image resized by with and height
<img src="{{action('media', ['id' => $default, 'width' => 300, 'heigth' => 300])}}" />
// this the full image resized by with and height in the canvas, not the image
<img src="{{action('media', ['id' => $default, 'width' => 300, 'heigth' => 300, 'canvas' => 'canvas'])}}" />

API

You can use the following methods with out the image selector modal.

ImageManager::doUpload(); //this method receives the input file like Input::file('file')
ImageManager::resize($id, $width = null, $height = null); //this method will render the image according to the parameters
ImageManager::imageInfo($id); //this method will return an instance of Joselfonseca\ImageManager\Models\ImageManagerFiles which is the eloquent model for the image_manager_files table for the id given.

Please report Bugs!

This is a new component that needs PR and bug report, use the repo to raise any issues.

To Do

    1. Unit Testing
    2. Image resizing and cropping
    3. Anything else cool!

Thanks!

I would like to thank anyone who uses the component and report bugs. This will always be a work in progress.

image-manager's People

Contributors

joselfonseca avatar

Watchers

 avatar  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.