PHPackages                             ixudra/imageable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. ixudra/imageable

ActiveLibrary[Image &amp; Media](/categories/media)

ixudra/imageable
================

Custom Laravel imaging package for the Laravel 5 framework - developed by Ixudra

8.1.0(2y ago)548911MITPHPPHP &gt;=7.2CI failing

Since Dec 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ixudra/imageable)[ Packagist](https://packagist.org/packages/ixudra/imageable)[ Docs](https://ixudra.be)[ RSS](/packages/ixudra-imageable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (16)Used By (1)

ixudra/imageable
================

[](#ixudraimageable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1cc996e65e4b8889689f6fde2268b8d227811e311cf70ff962bc5f9867c1f7a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6978756472612f696d61676561626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ixudra/imageable)![license](https://camo.githubusercontent.com/ed1eb4a23653705c5582a80744364d7e59f48e9a6b61db30b071a2892075d80d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6978756472612f696d61676561626c652e737667)[![Total Downloads](https://camo.githubusercontent.com/e5db1112dc61933728fbb85b4cbe08ad3270cad2d879cc07a13339ba0661f8bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6978756472612f696d61676561626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ixudra/imageable)

Custom Laravel imaging package for the Laravel 5 framework - developed by [Ixudra](http://ixudra.be).

The ixudra/imageable package provides an easy to use polymorphic image model that can be linked to one or more models in any Laravel PHP application. The package contains an image model class as well as a factory class that will take care of creating and editing the image model. Additionally, the package will also take care of moving and storing the actual files in the correct locations.

This package can be used by anyone at any given time, but keep in mind that it is optimized for my personal custom workflow. It may not suit your project perfectly and modifications may be in order.

Installation
------------

[](#installation)

Pull this package in through Composer:

```
    {
        "require": {
            "ixudra/imageable": "8.*"
        }
    }
```

Add the service provider to your `config/app.php` file:

```
    'providers'     => array(

        //...
        Ixudra\Imageable\ImageableServiceProvider::class,

    ),
```

Run package migrations using artisan:

```
    php artisan migrate --package="ixudra/imageable"
```

Alternatively, you can also publish the migrations using artisan:

```
    // Publish all resources from all packages
    php artisan vendor:publish

    // Publish only the resources of the package
    php artisan vendor:publish --provider="Ixudra\\Imageable\\ImageableServiceProvider"
```

Usage
-----

[](#usage)

Create a model with a polymorphic relationship to the `Image` model:

```
    use Ixudra\Imageable\Models\Image;
    use Ixudra\Imageable\Traits\ImageableTrait;

    class Card extends Eloquent {

        use ImageableTrait;

        protected $imagePath = 'images/cards';

        public function image()
        {
            return $this->morphOne( Image::class, 'imageable' );
        }

        public function delete()
        {
            $this->image->delete();

            parent::delete();
        }

    }
```

This class must extend the `Ixudra\Imageable\Traits\ImageableTrait` trait and must have the `imagePath` property available to it. The `imagePath` property describes the path to where the images need to be stored on the system. The package uses the `public/` directory as the starting point and will append the value of the `imagePath` value to it in order to derive the full path.

You can create new `Image` models using the `ImageFactory` class which is provided in the package. The `ImageFactory` will take care of creating the `Image` model, linking the `Image` to the designated model and moving the uploaded file to the location which is specified in the designated model.

The `ImageFactory` expects a specific set of input parameters:

- `file` which holds the actual uploaded file
- `alt` which holds the name of the image (will be used as `alt` when displaying the image)
- `title` which holds the name of the image (will be used as `title` when displaying the image)

Updating images works similar to creating them. All you need to do is provide the correct information and the `ImageFactory` will take care of the rest for you. It is also possible to update the image information without actually updating the uploaded file. This can be done by omitting the `file` attribute from the data that is passed to the factory.

A full example of a factory class that leverages the package functionality can be found in the following example:

```
    use Ixudra\Imageable\Services\Factories\ImageFactory;

    class CardFactory {

        protected $imageFactory;

        public function __construct(ImageFactory $imageFactory)
        {
            $this->imageFactory = $imageFactory;
        }

        public function create($input, $prefix = '')
        {
            $card = Card::create( array( 'name' => $input['name'] ) );
            $this->imageFactory->make( $input, $card, $prefix );

            return $card;
        }

        public function modify($card, $input, $prefix = '')
        {
            $card = $card->update( array( 'name' => $input['name'] ) );
            $this->imageFactory->modify( $card->image, $input, $card, $prefix );

            return $card;
        }

    }
```

Finally, the package also provides several views that can be used:

- `data.blade.php` which includes a Twitter Bootstrap implementation that will allow you to show the image on a page
- `fields.blade.php` which includes a Twitter Bootstrap implementation that can be included in forms to create and/or modify the image information

Usage example of both cases can be found in the examples below:

```
    {!! Form::open(array('url' => 'cards', 'method' => 'POST', 'id' => 'createCard', 'class' => 'form-horizontal', 'role' => 'form', 'files' => true)) !!}

                {!! Form::label('name', 'Name:', array('class' => 'control-label col-lg-3')) !!}

                    {!! Form::text('name', $input['name'], array('class' => 'form-control')) !!}
                    {!! $errors->first('name', ':message') !!}

        @include('imageable::images/fields', array( 'prefix' => 'image_' ))

            {!! Form::submit('Submit', array('class' => 'btn btn-primary')) !!}
            {!! HTML::linkRoute('cards.index', 'Cancel', array(), array('class' => 'btn btn-default')) !!}

    {!! Form::close() !!}
```

The fields.blade.php file by default assumes two variables:

- `$input`: associative array of default values of the input fields. Required keys: `title`, `alt`
- `$requiredFields`: array of input fields that the user is required to fill in. If the name of the field is in the array, a `required` property will be added to the form field, which can then be used to signal this to the user using CSS (not included)

Both of these variables need to be passed to the view in order to use the default views.

```

                Name:
                {{ $card->name }}

    @include('imageable::images/data', array('imageable' => $card))
```

The usage of these views is by no means required to take advantage of the functionality in this package. However, it is worth noting that both views leverage the functionality of the [ixudra/translation](http://github.com/ixudra/translation) package by default. The `ixudra/translation` package is not included as a requirement for this package, but must be pulled in via composer in order to take advantage of the views which are provided by default.

Planning
--------

[](#planning)

- Improve support for multiple images per model
- Add Javascript library to improve user interaction

Support
-------

[](#support)

Help me further develop and maintain this package by supporting me via [Patreon](https://www.patreon.com/ixudra)!!

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

Contact
-------

[](#contact)

For package questions, bug, suggestions and/or feature requests, please use the Github issue system and/or submit a pull request. When submitting an issue, always provide a detailed explanation of your problem, any response or feedback your get, log messages that might be relevant as well as a source code example that demonstrates the problem. If not, I will most likely not be able to help you with your problem. Please review the [contribution guidelines](https://github.com/ixudra/imageable/blob/master/CONTRIBUTING.md) before submitting your issue or pull request.

For any other questions, feel free to use the credentials listed below:

Jan Oris (developer)

- Email:
- Telephone: +32 496 94 20 57

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~225 days

Recently: every ~518 days

Total

15

Last Release

1011d ago

Major Versions

1.0.0 → 5.0.02015-04-24

5.1.0 → 6.0.02016-11-18

6.1.0 → 7.0.02017-09-05

7.2.1 → 8.0.02019-11-17

PHP version history (4 changes)1.0.0PHP &gt;=5.4.0

5.1.0PHP &gt;=5.6

7.0.0PHP &gt;=7.0

8.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c441bf73a59ca680bb804e22e746002a07d1a44542e8c417a45317bc79b224d8?d=identicon)[Elimentz](/maintainers/Elimentz)

---

Top Contributors

[![elimentz](https://avatars.githubusercontent.com/u/1410811?v=4)](https://github.com/elimentz "elimentz (25 commits)")

---

Tags

laravelimageIxudra

### Embed Badge

![Health badge](/badges/ixudra-imageable/health.svg)

```
[![Health](https://phpackages.com/badges/ixudra-imageable/health.svg)](https://phpackages.com/packages/ixudra-imageable)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[spescina/imgproxy

An image proxy for Laravel

201.3k](/packages/spescina-imgproxy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
