PHPackages                             eriktailor/filament-webp-uploads - 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. eriktailor/filament-webp-uploads

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

eriktailor/filament-webp-uploads
================================

Automatic WebP conversion for Filament FileUpload fields with optional resizing

3367↑114.3%3PHP

Since Jan 23Pushed 5mo agoCompare

[ Source](https://github.com/eriktailor/filament-webp-uploads)[ Packagist](https://packagist.org/packages/eriktailor/filament-webp-uploads)[ RSS](/packages/eriktailor-filament-webp-uploads/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Filament WebP Uploads
=====================

[](#filament-webp-uploads)

Automatic WebP conversion for Filament v4 FileUpload fields with optional resizing and quality control.

Features
--------

[](#features)

- 🎨 **Automatic WebP Conversion**: Converts uploaded images to WebP format automatically
- 📏 **Smart Resizing**: Optional image resizing with aspect ratio preservation (no upscaling)
- ⚙️ **Configurable Quality**: Control WebP compression quality per-field or globally
- 🔄 **Multiple Upload Support**: Works with both single and multiple file uploads
- 🛡️ **Safe Fallback**: Non-image files and conversion failures handled gracefully
- 📝 **Error Logging**: Failed conversions logged for debugging

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12+
- Filament v4.0+
- GD extension with WebP support

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

[](#installation)

Install the package via Composer:

```
composer require eriktailor/filament-webp-uploads
```

Optionally publish the config file:

```
php artisan vendor:publish --tag=filament-webp-uploads-config
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Replace Filament's `FileUpload` with `WebpFileUpload` and add the `->webp()` method:

```
use Eriktailor\FilamentWebpUploads\Components\WebpFileUpload;

WebpFileUpload::make('image')
    ->webp()
    ->disk('public')
    ->directory('images');
```

### Custom Quality

[](#custom-quality)

Specify WebP quality (1-100, default is 80):

```
WebpFileUpload::make('image')
    ->webp(90) // Higher quality, larger file size
    ->disk('public')
    ->directory('images');
```

### With Resizing

[](#with-resizing)

Add the `->resize()` method to limit maximum width (maintains aspect ratio):

```
WebpFileUpload::make('image')
    ->webp(85)
    ->resize(1920) // Max width 1920px
    ->disk('public')
    ->directory('images');
```

**Note**: Images smaller than the specified width will NOT be upscaled - they keep their original size.

### Multiple Uploads

[](#multiple-uploads)

Works seamlessly with multiple file uploads:

```
WebpFileUpload::make('gallery')
    ->multiple()
    ->webp(80)
    ->resize(1600)
    ->disk('public')
    ->directory('gallery');
```

### Complete Example

[](#complete-example)

```
use Eriktailor\FilamentWebpUploads\Components\WebpFileUpload;
use Filament\Forms\Components\Section;

Section::make('Media')
    ->schema([
        WebpFileUpload::make('featured_image')
            ->label('Featured Image')
            ->webp(90)
            ->resize(1920)
            ->image()
            ->maxSize(5120) // 5MB
            ->disk('public')
            ->directory('posts')
            ->required(),

        WebpFileUpload::make('gallery')
            ->label('Gallery')
            ->multiple()
            ->webp(85)
            ->resize(1600)
            ->image()
            ->maxFiles(10)
            ->disk('public')
            ->directory('posts/gallery'),
    ]);
```

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

[](#configuration)

The `config/filament-webp-uploads.php` file contains global defaults:

```
return [
    // Default WebP quality (1-100)
    'quality' => 80,

    // Default resize width in pixels (null = no resize)
    'resize_width' => null,
];
```

These defaults are used when `->webp()` or `->resize()` are called without arguments.

How It Works
------------

[](#how-it-works)

1. **File Upload**: User uploads an image through Filament FileUpload field
2. **MIME Check**: Plugin checks if file is an image (starts with `image/`)
3. **Resize** (optional): If configured and image is larger than target width, scales down maintaining aspect ratio
4. **Convert**: Image is converted to WebP format using Intervention Image v3 with GD driver
5. **Save**: WebP file is saved to configured storage disk/directory
6. **Fallback**: Non-images or conversion errors result in original file being saved

**Important**: Only the WebP version is saved - original files are not retained.

Error Handling
--------------

[](#error-handling)

- **Non-image files**: Silently saved as-is without conversion
- **Conversion failures**: Logged to Laravel log and original file saved as fallback
- **Missing GD/WebP**: Check your PHP installation has GD extension compiled with WebP support

Check logs at `storage/logs/laravel.log` for conversion errors.

Verifying WebP Support
----------------------

[](#verifying-webp-support)

Ensure your PHP installation supports WebP:

```
php -r "var_dump(gd_info());"
```

Look for `WebP Support => enabled` in the output.

Use Cases
---------

[](#use-cases)

- **Performance Optimization**: Reduce image file sizes by 25-80% compared to JPEG/PNG
- **Responsive Images**: Generate optimally sized images for different screen resolutions
- **Admin Panels**: Automatically optimize user-uploaded content in Filament admin interfaces
- **Content Management**: Streamline media management without manual image processing

Validation
----------

[](#validation)

The plugin does not automatically add image validation. Add your own validation as needed:

```
WebpFileUpload::make('image')
    ->webp(90)
    ->resize(1920)
    ->image() // Validates image MIME types
    ->acceptedFileTypes(['image/png', 'image/jpeg', 'image/webp'])
    ->maxSize(5120) // 5MB max
    ->required();
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Credits
-------

[](#credits)

- [Erik Tailor](https://github.com/eriktailor)
- Built with [Filament](https://filamentphp.com)
- Powered by [Intervention Image](https://image.intervention.io)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance49

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![eriktailor](https://avatars.githubusercontent.com/u/5834907?v=4)](https://github.com/eriktailor "eriktailor (2 commits)")

### Embed Badge

![Health badge](/badges/eriktailor-filament-webp-uploads/health.svg)

```
[![Health](https://phpackages.com/badges/eriktailor-filament-webp-uploads/health.svg)](https://phpackages.com/packages/eriktailor-filament-webp-uploads)
```

PHPackages © 2026

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