URL Image Uploader by Muhammad Amjad
CommunityA Filament form field for uploading an image by file or by URL, with server-side validation and configurable disk and directory, that works standalone or inside a Repeater for image galleries.
Author:
Muhammad Amjad
Package health
Automated checks of this plugin's Composer package
15 checks
- Passed: GitHub Actions pinned to SHA
- Skipped: GitLab CI includes pinned to SHA
- Passed: Open security advisories
- Passed: Dependabot PR responsiveness — No open Dependabot PRs.
- Skipped: Renovate MR responsiveness
- Failed: Dependabot or Renovate configured — No dependency updater configuration found. View details on Plumb
- Skipped: Dependency update cooldown configured
- Passed: Provides a security policy
- Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
- Passed: Commit and release recency — Active: last commit 8 days ago; last release 32 days ago.
-
Passed:
composer.lock not committed by library
—
composer.lockis absent from the released dist archive. - Passed: Dist archive is lean
-
Passed:
Current Laravel version supported
— Package dependencies resolve together with current Laravel
13.0. -
Passed:
Current PHP version supported
— Constraint
^8.3supports current PHP8.5. - Skipped: Current Symfony version supported
filament/
namespace. Review the source and install at your own risk. Found
malware or an unresolved security issue the author won't
address?
Report it
.
Documentation
- Supported versions
- Installation
- Usage
- Configuration
- Scope
- Upgrading from 1.x (Filament 3)
- Translations
- Testing
- Changelog
- Security Vulnerabilities
- Contributing
- License
A Filament form field with two tabs: upload an image file, or paste an image URL and fetch it server-side. Either way your model gets a plain storage path string.
#Supported versions
| Package | Filament | Laravel | PHP |
|---|---|---|---|
| 2.x | 4.x and 5.x | whatever your Filament version supports (11.28+, 12.x, 13.x) | 8.3+ |
1.x (1.x branch) |
3.x | whatever Filament 3 supports | 8.3+ |
#Installation
composer require amjadiqbal/filament-url-image-uploader
Composer picks the right major for your Filament version. Fetched and uploaded files are stored on
the public disk by default, so make sure it is linked:
php artisan storage:link
No panel plugin registration or asset build is needed: the field works in any Filament form.
#Usage
use AmjadIqbal\FilamentUrlImageUploader\Components\UrlImageUploader;
UrlImageUploader::make('image')->directory('images');
The field renders two tabs: upload a file directly, or paste an image URL and click Fetch Image
to download it server-side. Either way, the value saved to your model attribute is always a plain
storage path string (e.g. "images/example.jpg"), never an array, so no accessor or mutator is
needed on your model:
// database column: image (string, nullable)
class Post extends Model
{
protected $fillable = ['image'];
}
To render the stored image elsewhere in your app, resolve it through the disk you configured:
Storage::disk('public')->url($post->image);
#What the URL fetch checks
- Only
http://andhttps://URLs are fetched (file://,php://,data:and similar are refused). - The download is capped (10 MB by default) and has a 10 second timeout.
- The downloaded bytes must be an image (checked by content, not by file extension).
- Fetched files get a random filename prefix, so two URLs with the same basename never overwrite each other.
Each failure shows a Filament notification and stores nothing. A malformed URL left in the URL tab also blocks saving with a field error.
#File paths and Filament's tampering check
The field saves the storage path it was given, so it opts its inner upload out of
FileUpload::preventFilePathTampering() (opt-in from Filament 4.11 / 5.6, and on by default in the
Filament 6 development branch). That check compares a submitted path with the record's original
value for an attribute named like the upload; this field's inner upload is not a model attribute, so
with the check on every stored image would be rejected. As on Filament 4 and 5 today, a submitted
path is therefore not tied back to the record: if the disk holds files belonging to other users or
tenants, give each their own directory(). Filament 6 is not released and is not a supported
version of this package yet; this only keeps 2.x from failing on it.
#Configuration
#Directory
UrlImageUploader::make('image')->directory('custom/path/here');
#Disk
By default, files are stored on the public disk. You can target any configured disk:
UrlImageUploader::make('image')->disk('s3');
#Preserve original filenames
UrlImageUploader::make('image')->preserveFilenames();
With this on, a fetched file keeps its original name, and gets a -1, -2, ... suffix instead of
overwriting a file that already exists.
#URL fetch size limit
UrlImageUploader::make('image')->maxUrlFetchSize(5 * 1024 * 1024); // 5 MB
#Scope
UrlImageUploader manages a single image per field. It does not support Filament's multiple()
mode. For a gallery of several images, use a Repeater of them.
#Using it in a Repeater (image gallery)
use Filament\Forms\Components\Repeater;
Repeater::make('gallery')
->schema([
UrlImageUploader::make('image')->directory('gallery'),
])
->reorderable()
->addable()
->deletable();
Each row gets its own instance of the field, so adding, deleting and reordering rows keeps every
image with its own row. This is covered by a dedicated test suite
(tests/Feature/RepeaterGalleryTest.php).
Gotcha: while a row is being edited, its live state is the field's internal {path, url}
shape, not the flat string your model attribute ends up with. If you add an itemLabel() that reads
the row's image value, read $state['image']['path'] ?? null (an array), or don't key the label off
this field at all.
#Upgrading from 1.x (Filament 3)
Upgrade Filament itself first (see Filament's upgrade guide), then:
composer require amjadiqbal/filament-url-image-uploader:^2.0
The field's PHP API (make(), directory(), disk(), preserveFilenames(), maxUrlFetchSize())
and the stored value are unchanged, so your forms and data need no changes. Published translations
still apply.
#Translations
All user-facing strings ship in English by default. Publish them to customize or translate:
php artisan vendor:publish --tag="filament-url-image-uploader-translations"
#Testing
composer test # PHPUnit, via Orchestra Testbench
composer analyse # Larastan/PHPStan (level 5)
composer format # Laravel Pint
scripts/ci-local.sh # all of the above on PHP 8.3 and 8.4, against Filament 5 and Filament 4
#Changelog
Please see CHANGELOG.md for what changed in each release.
#Security Vulnerabilities
Please report security issues privately through GitHub's private vulnerability reporting. See SECURITY.md.
#Contributing
Contributions are welcome. See CONTRIBUTING.md (CI for this repo runs locally).
#Custom Development
Hire me on Upwork for:
- Package integration
- Custom feature development
- Technical consultation
- Project implementation
#Community Support
For priority support and enterprise solutions, please reach out via Upwork for direct assistance.
#License
MIT. See LICENSE.
The author
I am a seasoned full-stack web developer specializing in Laravel, Livewire, and Vue.js ecosystems. With extensive experience in building modern web applications, I leverage the power of Laravel's elegant syntax and robust features to create scalable backend solutions. My expertise extends to crafting responsive and interactive user interfaces using Livewire and Vue.js, enhanced by the utility-first approach of Tailwind CSS.
From the same author
Record Settings
Edit per-user, per-team and per-tenant settings in Filament from a settings page, a modal action or resource form fields, stored with glorand/laravel-model-settings or in a JSON column.
Author:
Muhammad Amjad
Uptime Monitor
An admin UI for spatie/laravel-uptime-monitor that lets you add, edit, turn on and off and check uptime and SSL certificate monitors from your Filament panel, with status filters and a dashboard widget.
Author:
Muhammad Amjad
Stat Cards
Richer stat cards for the Filament stats overview widget, adding progress bars, icon tiles, background, label and value colours, trends, badges and bar charts to the widget you already have.
Author:
Muhammad Amjad
XLSX Import
Lets Filament's own ImportAction read Excel (.xlsx) and OpenDocument (.ods) workbooks as well as CSV, with a sheet picker, while your existing Importer classes, queued jobs and failed-rows downloads keep working unchanged.
Author:
Muhammad Amjad
Featured Plugins
A selection of plugins curated by the Filament team
Noir Theme
A theme that gives panels a focused, refined look with near-black surfaces, crisp actions, and restrained color.
Filament
Compact Theme
A theme that makes data-heavy panels easier to scan by fitting more useful information on each screen.
Filament
Advanced Tables (formerly Filter Sets)
Supercharge your tables with powerful features like user-customizable views, quick filters, multi-column sorting, advanced table searching, convenient view management, and more. Compatible with Resource Panel Tables, Relation Managers, Table Widgets, and Table Builder!
Kenneth Sese