PHPackages                             carrooi/images-manager - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. carrooi/images-manager

ActiveLibrary[File &amp; Storage](/categories/file-storage)

carrooi/images-manager
======================

Images manager for Nette framework

4.0.0(9y ago)86.1k1[1 issues](https://github.com/Carrooi/Nette-ImagesManager/issues)MITPHPPHP &gt;=5.6

Since Sep 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Carrooi/Nette-ImagesManager)[ Packagist](https://packagist.org/packages/carrooi/images-manager)[ Docs](https://github.com/Carrooi/Nette-ImagesManager/issues)[ RSS](/packages/carrooi-images-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (16)Used By (0)

Images manager
==============

[](#images-manager)

[![Build Status](https://camo.githubusercontent.com/338eebc3ff19b85a8a486a2a5b3563e896e494878db8653a3a9f77aa7b924490/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f436172726f6f692f4e657474652d496d616765734d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Carrooi/Nette-ImagesManager)[![Donate](https://camo.githubusercontent.com/7f8b0c0980ad316210d1ec0c7d3298ace87d2f7c0eb6911977c0644951af5bd2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d50617950616c2d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=39WBDGLHF48PE)

Simple to use tool for managing uploaded images.

BC break!
---------

[](#bc-break)

**Be careful, version 3.0 was completely rewritten.**

If you are using just latte templates and uploading images, it should be enough just to move `basePath` and `baseUrl`configuration under the `storage` section.

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

[](#installation)

```
$ composer require carrooi/images-manager
$ composer update

```

**config.neon:**

```
extensions:
	images: Carrooi\ImagesManager\DI\ImagesManagerExtension

images:
	storage:
    	basePath: %appDir%/../www/uploads
        baseUrl: http://www.site.com/uploads
```

Namespaces
----------

[](#namespaces)

On your website you can have many different types of images. For example users' images, articles' images and so on. But you also want to keep them separate and this is where namespaces came from.

Namespace is actually just a directory in chosen path (in our example `%appDir%/../www/uploads`)

This means that users' images will be saved here: `%appDir%/../www/uploads/user`.

Only thing you need to do is create this directory.

Saving images
-------------

[](#saving-images)

There is automatically registered "manager" service for handling all images operations, so lets include it and than use it (presenter will be enough for this example)

```
use Nette\Application\UI\Presenter;
use Nette\Application\UI\Form;

class ImagesPresenter extends Presenter
{

	/** @var \Carrooi\ImagesManager\ImagesManager @inject */
	public $imagesManager;

	/**
	 * @return \Nette\Application\UI\Form
	 */
	protected function createComponentForm()
	{
		$form = new Form;

		$form->addUpload('image', 'Image')
			->addRule(Form::IMAGE);

		$form->addSubmit('save', 'Upload');

		$form->onSuccess[] = [$this, 'uploadImage'];

		return $form;
	}

	/**
	 * @param \Nette\Application\UI\Form $form
	 * @param mixed $values
	 */
	public function uploadImage(Form $form, $values)
	{
		if ($values->image->isOk()) {
			$image = $values->image->toImage();
			$namespace = 'users';
			$name = 'david.jpg';

			$this->imagesManager->upload($image, $namespace, $name);

			// @todo: show flash message and redirect

		} else {
			// @todo: show error
		}
	}

}
```

As you can see, isn't really simple, just call upload with desired image, namespace and final name. That's it :-)

But be careful, if there is already image with name `david.jpg` in `users` namespace, it will be removed with all its thumbnails as well.

Latte templates
---------------

[](#latte-templates)

This step also couldn't be easier, because there are some Latte macros prepared for you.

The nice thing about this package is that you don't need to worry about browsers cache. Increasing version number is automatically appended to all URLs, so browser will always try to load new images when you change it.

**original image:**

```

```

**thumbnail with width:**

```

```

**thumbnail with width and height:**

```

```

**thumbnail with different resize method (default is [fit](http://api.nette.org/2.2.2/source-Utils.Image.php.html#106-107)):**

```

```

You can even use names without files' extensions and images-manager will try to find it for you:

```

```

**Found files' extensions are cached, so if you change some image in other way than with `ImagesManager`, you'll have to delete the cache yourself.**

### Other Latte macros

[](#other-latte-macros)

**image:**

```
Image path: {image users, 'david.jpg', '50x50'}
```

**is-image (with alias isImage):**

```

```

**is-not-image (with alias isNotImage):**

```

	Upload your image now!

```

Default images
--------------

[](#default-images)

Maybe you will want some default image. Users are again great example, because it is quite usual to have some default avatar. Default name of default image is `default.jpg` and it needs to be in desired namespace directory.

```
images:
	default: default.png
```

### Dummy images

[](#dummy-images)

When even default image does not exists, you can show some dummy image (like cute cats). This is possible because of [lorempixel](http://lorempixel.com/) service.

```
dummy:
	enabled: true
    category: cats
    fallbackSize: [800, 600]
    chance: 100
```

- `fallbackSize`: image resolution used when no size is given in latte template
- `chance`: percentage chance that instead of no image, you'll see cute cat

Entities, DTOs and so on instead of string names
------------------------------------------------

[](#entities-dtos-and-so-on-instead-of-string-names)

With default setup, you have to use string names like `david.jpg`. But for users it would be better to use eg. their entities directly. You just have to configure custom namespace setup with own name resolver.

```
use Carrooi\ImagesManager\INameResolver;
use App\Model\Entities\User;

class UserEntityNameResolver implements INameResolver
{

	/**
	 * @param \App\Model\Entities\User $user
	 * @return string
	 */
	public function translateName($user)
	{
		if (!$user instanceof User) {
			throw new \Exception;		// todo: better exception
		}

		return $user->getId();		// just like with string names
	}

	/**
	 * @param \App\Model\Entities\User $user
	 * @return string
	 */
	public function getDefaultName($user)
	{
		if (!$user instanceof User) {
			throw new \Exception;		// todo: better exception
		}

		return $user->getGender()->getName();
	}

}
```

**configuration:**

```
images:
	namespaces:
		user:
			nameResolver: App\Images\UserEntityNameResolver
```

Quality of images
-----------------

[](#quality-of-images)

Quality of jpg and png images can be customized. This can be done either globally for all image namespaces or for each image namespace separately.

```
images:
	quality: 90
    namespaces:
    	user:
        	quality: 100
```

Presets
-------

[](#presets)

If you are using specific sizes of images many time, it will be a good idea to create preset from such size. You can save all your images' sizes into configuration under some names and than use these names.

This is really good when you'll need to change some size in a future, you'll have to change it only in configuration.

**configuration:**

```
images:
	namespaces:
		user:
			presets:
				small: 10x20(shrinkOnly, stretch)
				medium: 40x50(fit)
				large: 400x500
```

**template:**

```

```

which is same as:

```

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 98.8% 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 ~70 days

Recently: every ~154 days

Total

15

Last Release

3287d ago

Major Versions

1.1.0 → 2.0.02015-06-09

2.1.4 → 3.0.02015-10-21

3.1.1 → 4.0.02017-05-18

PHP version history (2 changes)3.0.0PHP &gt;= 5.5

4.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/838c6933d498fdb2a31f251ed45006a6ef97935ea2a27f38dab7738038939fc9?d=identicon)[david\_kudera](/maintainers/david_kudera)

---

Top Contributors

[![davidkudera](https://avatars.githubusercontent.com/u/1174072?v=4)](https://github.com/davidkudera "davidkudera (80 commits)")[![josefzajac](https://avatars.githubusercontent.com/u/8426378?v=4)](https://github.com/josefzajac "josefzajac (1 commits)")

---

Tags

netteimageloaderstoragemanagersource

### Embed Badge

![Health badge](/badges/carrooi-images-manager/health.svg)

```
[![Health](https://phpackages.com/badges/carrooi-images-manager/health.svg)](https://phpackages.com/packages/carrooi-images-manager)
```

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[contributte/image-storage

Image storage for Nette framework

28749.3k1](/packages/contributte-image-storage)[ublaboo/image-storage

Image storage for Nette framework

2913.0k](/packages/ublaboo-image-storage)[noam148/yii2-image-manager

A Yii2 module/widget for upload and cropping images

12914.8k](/packages/noam148-yii2-image-manager)[edsdk/flmngr-server-php

Flmngr file manager PHP backend

20279.5k3](/packages/edsdk-flmngr-server-php)[itskodinger/midia

Simple Media manager for your Laravel project

1415.8k](/packages/itskodinger-midia)

PHPackages © 2026

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