PHPackages                             tacoberu/nette-media - 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. tacoberu/nette-media

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

tacoberu/nette-media
====================

On-the-fly generated web images for your Nette app. Very inspired (and copy) from dotBlue (http://dotblue.net).

v3.0.2(1y ago)039MITPHPPHP &gt;=7.4

Since Dec 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tacoberu/nette-media)[ Packagist](https://packagist.org/packages/tacoberu/nette-media)[ RSS](/packages/tacoberu-nette-media/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (9)Versions (13)Used By (0)

Nette media
===========

[](#nette-media)

Manage and provide files and images in Nette. On-the-fly generated images thumbnails. Very inspired (and copy) from dotBlue ().

We usually want to upload some files or images that we store in one or more repositories (this is not part of this project). We usually want to access files in a nice, configurable way. We want to create some operations, previews, watermarks on images. We usually want to generate previews only when needed and if possible only once. We want to access the resulting previews directly, using mod\_rewrite (or a similar technique) to make it as fast as possible. It also comes in handy, allowing you to force an image download.

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

[](#installation)

The recommended way to install is via Composer:

```
composer require tacoberu/nette-media

```

Using in a template
-------------------

[](#using-in-a-template)

Original image:

```

```

It will generate:

```
/media/users/david.jpg

```

Image preview. We choose from predetermined variants (protection against DoS). The preview is generated automatically on request and saved for the next time.

```

```

It will generate:

```
/media/users/david.jpg?small

```

Image forced to download:

```

```

It will generate:

```
/media/users/david.jpg?download

```

And non-image file:

```

```

Configuration
-------------

[](#configuration)

```
extensions:
	media: Taco\NetteMedia\Extension

media:
	# Where source images are taken.
	providers:
		- Taco\NetteMedia\FileBasedProvider(%appDir%/../../var/uploads)

	# We need to deduce from the url that it is an image, and in which variant we get it
	route: Taco\NetteMedia\Router('media')

	# Transform over images. Typically previews.
	transformations:
		preview:
			- Taco\NetteMedia\ResizeTransformation(75, 250, 250, 'fit')
		medium:
			- Taco\NetteMedia\ResizeTransformation(75, 264, 264, 'fit')
		small:
			- Taco\NetteMedia\ResizeTransformation(75, 100, 100, 'fit')
		big:
			- Taco\NetteMedia\ResizeTransformation(100, 800, 600, 'fit')
			# - YourApp\NetteMedia\WatterMark

	# Where the previews are stored. It is possible to set it to public and configure .htaccess
	cache: Taco\NetteMedia\FileBasedThumbnailCache(%wwwDir%/cache)

```

Sample .htaccess
----------------

[](#sample-htaccess)

It's nice that the system generates a preview for us on-the-fly. But even those previews have to be accessed via Nette, which would be better. Let's add (manually) such .htaccess rules.

```
# cached image previews
RewriteCond %{REQUEST_URI} ^/media/(.+)$
RewriteCond %{QUERY_STRING} ^(preview|medium|small|big)$
RewriteRule ^media/(.*)$ /cache/%{QUERY_STRING}/$1 [L]

# cached image original
RewriteCond %{REQUEST_URI} ^/media/(.+)$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^media/(.*)$ /cache/__orig__/$1 [L]

# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

```

Now it should work like this:

- We will display the url /media/users/david.jpg?preview
- We find that the preview of the image does not exist, so the original image is extracted and the preview transformation is performed on it.
- The result is saved in %wwwDir%/cache/preview
- The next time you access it, the image is already found in /cache/preview/users/david.jpg and displayed right away before php is used.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

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 ~179 days

Recently: every ~20 days

Total

12

Last Release

727d ago

Major Versions

v2.5.x-dev → v3.0.02024-05-04

PHP version history (2 changes)v2.3.x-devPHP &gt;=5.4

v2.5.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d9535bc57ab9e7c844b76be57d024b97eb84e9f8a9d308537afffe9cf81c409?d=identicon)[tacoberu](/maintainers/tacoberu)

---

Top Contributors

[![tacoberu](https://avatars.githubusercontent.com/u/1828339?v=4)](https://github.com/tacoberu "tacoberu (19 commits)")

---

Tags

netteroutingimagesmedia

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tacoberu-nette-media/health.svg)

```
[![Health](https://phpackages.com/badges/tacoberu-nette-media/health.svg)](https://phpackages.com/packages/tacoberu-nette-media)
```

###  Alternatives

[dotblue/nette-webimages

On-the-fly generated web images for your Nette app

272.1k](/packages/dotblue-nette-webimages)[brabijan/images

Image storage for Nette Framework

5617.7k](/packages/brabijan-images)[tomaj/nette-api

Nette api

36261.8k4](/packages/tomaj-nette-api)[pavlista/nette-palette

Palette support for Nette Framework and Latte template engine

1657.4k](/packages/pavlista-nette-palette)[kollarovic/thumbnail

Generating image thumbnails

1035.5k2](/packages/kollarovic-thumbnail)

PHPackages © 2026

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