Download the PHP package moonlight-poland/laravel-context-aware-thumbnails without Composer

On this page you can find all versions of the php package moonlight-poland/laravel-context-aware-thumbnails. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-context-aware-thumbnails

πŸ–ΌοΈ Laravel Context-Aware Thumbnailsβ„’

Intelligent On-Demand Image Thumbnails with Smart Crop & Modern Formats

Copyright Β© 2024-2026 Moonlight Poland. All rights reserved.
Contact: [email protected]
License: Commercial License - Free for personal use, paid for commercial use
Repository: https://github.com/Moonlight4000/laravel-thumbnails

Latest Version on Packagist Total Downloads

Generate image thumbnails on-the-fly in Laravel with Context-Aware Thumbnailsβ„’ - the only package that organizes thumbnails exactly where your content lives!

No pre-generation needed. No Redis required. Smart organization included.β„’

🌟 What Makes Us Unique?

  1. 🎯 Context-Aware Organizationβ„’ - Thumbnails organized by user/post/album (no other package does this!)
  2. βš›οΈ React/Vue/JavaScript Support - The ONLY Laravel thumbnail package with sync-js command for frontend frameworks
  3. πŸ” Signed URLs (Facebook-style) - Time-limited, cryptographically signed URLs to prevent hotlinking
  4. πŸ€– Smart Crop with AI Energy Detection - Automatically focuses on important image areas
  5. πŸš€ AVIF/WebP Support - Modern formats for 50%+ smaller file sizes
  6. πŸ”’ Commercial Licensing - Professional support & tamper detection included

πŸ“‹ Table of Contents


πŸ† Why Choose This Over Other Packages?

πŸ“Š Complete Feature Comparison

Feature Laravel Smart Thumbnailsβ„’
(moonlight-poland)
askancy/
laravel-smart-thumbnails
lee-to/
laravel-thumbnails
spatie/
laravel-medialibrary
🎯 UNIQUE FEATURES
Context-Aware Organizationβ„’ βœ… ONLY US! ❌ ❌ ❌
Custom path templates βœ… {user_id}/{post_id} ❌ ❌ ⚠️ Limited
Per-user/post isolation βœ… Built-in ❌ Manual ❌ Manual ⚠️ Via DB
Commercial licensing βœ… $500-$15k ❌ MIT (free) ❌ MIT βœ… Spatie
πŸ–ΌοΈ IMAGE PROCESSING
AVIF format support βœ… v2.0+ βœ… ❌ βœ…
WebP format support βœ… v2.0+ βœ… ❌ βœ…
Smart Crop (AI energy) βœ… v2.0+ βœ… ❌ βœ…
Crop/Fit/Resize methods βœ… All 3 βœ… SmartCrop βœ… All 3 βœ… Yes
Multiple drivers βœ… GD/Imagick/Intervention βœ… GD/Imagick ⚠️ Intervention only βœ… Yes
Quality control βœ… Per size βœ… Per variant βœ… Global βœ… Yes
πŸ›‘οΈ ERROR HANDLING
Silent/Strict modes βœ… v2.0+ βœ… ❌ ⚠️ Limited
Bulletproof fallbacks βœ… βœ… ⚠️ Basic βœ…
Never breaks app βœ… βœ… ⚠️ Can throw βœ…
⚑ GENERATION
On-demand (lazy) βœ… Automatic βœ… Automatic βœ… Manual βœ… Manual
Middleware fallback βœ… Auto 404β†’generate ❌ ❌ ❌
Zero config βœ… Works out-of-box ⚠️ Requires setup ⚠️ Setup needed ❌ Complex
πŸ“ ORGANIZATION
Subdirectory strategies βœ… Context-aware βœ… 5 strategies ❌ Flat ⚠️ Via DB
Hash-based distribution ⚠️ Manual βœ… Automatic ❌ ❌
Date-based folders ⚠️ Manual βœ… Automatic ❌ ❌
Handles millions of files βœ… Yes βœ… Yes ⚠️ Slow βœ… Yes
🎨 VARIANTS & PRESETS
Multiple sizes per preset βœ… βœ… Variants βœ… βœ…
Responsive images βœ… βœ… βœ… βœ…
Named presets βœ… 'small', 'large' βœ… βœ… βœ…
πŸ”§ DEVELOPER EXPERIENCE
Blade directive βœ… @thumbnail() ❌ ❌ ❌
Helper function βœ… thumbnail() ❌ βœ… ❌
Eloquent trait βœ… HasThumbnails ❌ βœ… βœ…
React/Vue/JS βœ… ONLY US! ❌ ❌ ❌
Auto-sync JS helper βœ… sync-js ❌ ❌ ❌
Artisan commands βœ… generate, clear, sync-js βœ… purge, optimize ❌ βœ… Many
πŸ“Š MONITORING
Statistics & analytics βœ… v2.0+ βœ… Full ❌ βœ…
Performance metrics βœ… v2.0+ βœ… ❌ ⚠️
Disk usage tracking βœ… v2.0+ βœ… ❌ βœ…
πŸ”’ SECURITY
File validation βœ… v2.0+ βœ… ⚠️ Basic βœ…
Size limits βœ… v2.0+ βœ… ❌ βœ…
Extension whitelist βœ… v2.0+ βœ… ❌ βœ…
Signed URLs (Facebook-style) βœ… v2.0.16+ ❌ ❌ ⚠️ Via S3
Time-limited links βœ… v2.0.16+ ❌ ❌ ❌
Hotlinking prevention βœ… v2.0.16+ ❌ ❌ ⚠️ Via S3
Tamper detection βœ… Commercial only ❌ ❌ ❌
πŸ’Ύ STORAGE
Filesystem cache βœ… βœ… βœ… βœ…
Redis/Memcached tags ❌ βœ… ❌ ⚠️
Multi-disk support βœ… βœ… βœ… βœ…
S3/Cloud storage βœ… βœ… βœ… βœ…
Database storage ❌ ❌ ❌ βœ…
πŸ“¦ INSTALLATION
Installs πŸ†• New 17 ~500 50,000+
Stars ⭐ New 1 ~50 5,000+
Maturity βœ… v3.2.0 πŸ†• v2.0 ⚠️ v1.x βœ… v11.x

🎯 Which Package Should You Choose?

Choose Laravel Context-Aware Thumbnailsβ„’ (moonlight-poland) if you need:


πŸ”₯ What Makes Context-Aware Thumbnailsβ„’ Special?

Other packages dump all thumbnails in one folder. We organize them exactly where your content lives:

Benefits:


⚠️ License Notice

This is a COMMERCIAL package with a dual-licensing model:

See LICENSE.md for details.

Contact: [email protected]
GitHub: https://github.com/Moonlight4000/laravel-thumbnails


✨ Features


πŸ“¦ Installation

Optional Dependencies (Recommended)

For best performance and advanced features, install these optional packages:

What you get with optional dependencies:

License

Put your licence key in .env:

Local development on localhost / 127.0.0.1 / ::1 needs no key β€” in the local and testing environments only.

How the check behaves (3.2.0+):

Verify now β€” and schedule it daily, so the check never runs during a page request:

Setting Default Meaning
THUMBNAILS_LICENSE_CACHE_DAYS 30 how long a verified licence is trusted without asking again
THUMBNAILS_LICENSE_TIMEOUT 2 seconds one verification attempt may take
THUMBNAILS_LICENSE_GRACE_DAYS 90 days past its expiry the last licence keeps working while the server is unreachable

Contact for licensing: [email protected]

Optional: Publish Config

Make Sure Storage is Linked

For React/Vue Apps: Generate JS Helper

REQUIRED if using React, Vue, or any JavaScript framework:

This generates resources/js/utils/thumbnails.js with your config contexts.

When to run:

See React/Vue Usage section below for details.


πŸš€ Quick Start

Basic Usage (Blade)

That's it! πŸŽ‰


πŸ”₯ Context-Aware Thumbnailsβ„’ (UNIQUE FEATURE!)

The only Laravel package that organizes thumbnails exactly where your content lives!

Why Context Matters

Traditional packages dump all thumbnails into one folder. This causes:

Context-Aware Thumbnailsβ„’ solves this:

Configuration

Define custom contexts in config/thumbnails.php:

PHP Usage

Model Integration

Benefits

βœ… Perfect organization - thumbnails live with their content
βœ… Easy cleanup - delete post folder, thumbnails gone
βœ… Per-user isolation - great for multi-tenant apps
βœ… CDN-friendly - route /user-posts/1/* to User 1's CDN
βœ… Faster backups - backup specific content types
βœ… Better performance - fewer files per directory


🎨 React / Vue / JavaScript Usage

🌟 UNIQUE FEATURE: We are the ONLY Laravel thumbnail package that provides seamless React/Vue/JavaScript integration with automatic context synchronization! Other packages only work with Blade.

IMPORTANT: For React/Vue apps, you need to generate a JavaScript helper that mirrors your PHP config.

Step 1: Generate JS Helper

This creates resources/js/utils/thumbnails.js with your contexts from config/thumbnails.php.

Run this command whenever you:

Step 2: Import in React/Vue

βœ… YES, the import is REQUIRED! Without it, your React/Vue components won't have thumbnail URLs.

Available Functions

βœ… Full Feature Parity with PHP

JavaScript helper supports ALL PHP features:

Example with all options:

PHP Backend Setup for React

In your PHP accessor (e.g., UserPost.php):

React will:

  1. Call getThumbnailUrl(media.path, 'small')
  2. Build URL: /storage/user-posts/1/12/thumbnails/img_thumb_small.jpg
  3. Browser requests thumbnail
  4. 404 on first request β†’ middleware generates thumbnail
  5. 200 on next requests β†’ cached file served by Nginx

Workflow

Vue Example


πŸ“¦ Benefits

  1. βœ… Automatic Cleanup - Delete post folder = all thumbnails gone
  2. βœ… Per-User Isolation - Easy permissions & backups per user
  3. βœ… CDN Routing - Route different contexts to different CDNs
  4. βœ… Performance - Fewer files per directory = faster filesystem
  5. βœ… Organization - Find any thumbnail instantly
  6. βœ… Scalability - No "one folder with million files" problem

πŸ“ Resize Methods

Choose how thumbnails should be generated:

1. Resize (Default - Proportional)

Use for: Product images, photos where full content must be visible

2. Crop (Exact Size - Center Crop)

Use for: Avatars, thumbnails in grids, cards

3. Fit (Preserve All - Add Padding)

Use for: Logos, icons, images where nothing can be cut

Visual comparison:


πŸ“š Usage Methods

1. Blade Directive

2. Facade

3. Helper Functions

4. Service Injection

5. JavaScript (Frontend)


βš™οΈ Configuration

Default Sizes

Drivers

GD (built-in, no extra dependencies)

Imagick (better quality, requires ext-imagick)

Intervention Image (most features, requires package)

Quality & Performance


🎯 Advanced Features

HasThumbnails Trait

Automatically delete thumbnails when model is deleted:

Artisan Commands

Manual Management


πŸ†• V2.0 New Features

Smart Crop (AI Energy Detection)

Automatically detect the most important part of the image for intelligent cropping:

Usage:

When to use:


Modern Image Formats (AVIF/WebP)

Write thumbnails in a modern format with one setting (3.2.0+):

Never build a thumbnail name by substituting the source's extension yourself β€” once format is set, photo.jpg has a thumbnail called photo_thumb_small.webp. Ask the package:

AVIF needs GD built with AVIF support (PHP 8.1+) or the Imagick driver. AVIF sources are decoded as well.

The older formats block (auto_convert, priority) in the published config was never read by the package. It is kept only so existing config files do not change.


πŸ” Laravel Native Signed URLs Integration

Version 2.0.18+ uses Laravel's native URL::temporarySignedRoute() for signed URLs instead of custom Facebook-style implementation.

βš™οΈ Setup

Since 3.0 the package registers /storage/{path} (route name storage.serve) and its controller itself β€” skip steps 1 and 2 below. They describe the setup of 2.x. Adding your own route replaces the package's, and with it the package's checks (signature, expiry, and since 3.2.0 the refusal of .. in the path). Steps 3 and 4 still apply.

1️⃣ Create StorageController (2.x only β€” not needed since 3.0)

Create app/Http/Controllers/StorageController.php:

2️⃣ Add Route with Signed Middleware (2.x only β€” the package registers it since 3.0)

Add to routes/web.php:

⚠️ IMPORTANT: Place this route BEFORE any catch-all routes!

3️⃣ Disable Laravel's Auto-Routes

In config/filesystems.php, set serve => false:

4️⃣ Remove public/storage Symlink

Laravel should route ALL /storage/* requests through the controller:

Why remove it?


🎯 Enable Signed URLs

In .env:

Generated URLs:


✨ How It Works

  1. original() / thumbnail() helpers generate signed URL using URL::temporarySignedRoute()
  2. Browser requests the signed URL
  3. The package's StorageFileController validates expires and signature, and refuses any path with a .. segment
  4. If valid: the file is served with Cache-Control: public, max-age=<expiration>
  5. If invalid/expired: 403

ThumbnailFallback Middleware:


πŸ—“οΈ Stable URLs (stable_window, 3.2.0+)

By default every render stamps the current second into expires, so the same thumbnail gets a different URL on every page view β€” and the browser can never reuse what it has already downloaded. Turn on the stable window and the URL stays byte-identical for the whole window:


πŸ“Š URL Expiration Times


πŸ”’ Security Benefits


πŸ› Troubleshooting

Images still load after expiration?

403 Invalid signature on valid URLs?

React/Vue images not loading?


Usage with Blade directive:

File size comparison:


Variants System (Generate Multiple Sizes)

Generate multiple thumbnail sizes at once with preset collections:

Usage:

When to use:


Subdirectory Strategies (Performance at Scale)

Choose how thumbnails are organized on the filesystem:

Performance Benefits:

Files Without Subdirs With Hash Prefix
1,000 ⚠️ Slow βœ… Fast
10,000 ❌ Very Slow βœ… Fast
100,000 ❌ Unusable βœ… Fast
1,000,000 ❌ Impossible βœ… Fast

Why: Operating systems slow down with >1000 files per directory.


Security Validation

Protect against malicious file uploads:

Automatic validation: Package validates all images before processing.


Error Handling Modes

Control how the package behaves when errors occur:

Modes:

Example:


Daily Usage Statistics (Privacy-Friendly)

Track thumbnail usage for analytics (commercial license holders only):

What's tracked:

What's NOT tracked:

View statistics: Commercial license holders can view stats at https://howtodraw.pl/developer/licenses


πŸ—οΈ How It Works

Architecture

File Structure

Before first request:

After thumbnail request:


πŸ’Ό Licensing

Choose Your License

License Price Best For Limits
Personal FREE Hobby projects, open-source Non-commercial only
Small Business $500/year Startups, freelancers 1-10 devs, <$500k revenue
Medium Business $1,500/year Growing companies 11-50 devs, $500k-$10M revenue
Enterprise $15,000/year Large corporations 50+ devs, unlimited

Full details: LICENSE.md

Contact for commercial licensing: [email protected]

Why Commercial License?


πŸ†š Comparison

Feature This Package Traditional Solutions
Generation On-demand (lazy) Pre-generate all sizes
Performance Fast (only needed) Slow (generates unused)
Storage Efficient Wastes space
Setup Zero config Complex setup
Cache Filesystem Often needs Redis
Dependencies ext-gd (built-in) Various

πŸ“– Examples

Gallery with Thumbnails

Responsive Images

React Component


🀝 Contributing

This is a commercial package. We welcome:

Contact: [email protected]


πŸ“„ License

Commercial License with free personal tier.

See LICENSE.md for full terms.


πŸ’ Credits

Inspired by:

Built with ❀️ by Moonlight Poland Team


πŸ“ž Support

GitHub Issues: https://github.com/Moonlight4000/laravel-thumbnails/issues
Email: [email protected]


⭐ If this package helped you, please star it on GitHub!


All versions of laravel-context-aware-thumbnails with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2|^8.3
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/filesystem Version ^10.0|^11.0|^12.0
ext-gd Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package moonlight-poland/laravel-context-aware-thumbnails contains the following files

Loading the files please wait ...