v4.4.2 - Configurable media disk + media library bug fixes
π Thanks to @jakublacko
This release is shipped almost entirely thanks to a thorough community contribution from @jakublacko in #71. Beyond the headline feature, the PR uncovered and fixed a string of latent bugs in the media library subsystem that had been quietly degrading API uploads and the edit-media flow. The PR also came with 600+ lines of new test coverage. Excellent work β much appreciated.
New: configurable media disk
- New env var
TALLCMS_MEDIA_DISKlets installs route media to any filesystem disk defined inconfig/filesystems.php(custom-named S3 buckets, R2, local, etc.) instead of TallCMS's auto-detection betweens3andpublic. - The media disk is now centralised through
cms_media_disk(), so every controller, page, and resource in the media flow consults the same source of truth. cms_uses_s3()now does driver-based detection instead of literal-name matching, so disks named anything other than's3'are correctly recognised when their underlying driver is S3.
Set TALLCMS_MEDIA_DISK=my-bucket in .env and TallCMS will use that disk for all new media operations. Leave it unset for the existing auto-detect behaviour.
Bug fixes
- API media uploads silently dropped image dimensions.
MediaController::store()was writingwidth/heightas top-level columns, but those aren't$fillableβ and the model reads them frommeta['width']/meta['height']via accessors. Dimensions now persist correctly. MediaController::destroy()had a dead manual variant cleanup loop that read a non-existentvariantscolumn. Removed; the model'sdeletinghook already handles file + variant cleanup viaImageOptimizer::deleteVariants().- Filament edit-media page didn't capture dimensions on non-public disks. Brought to parity with the create page's temp-file download approach.
MediaController::store()accepted a caller-supplieddiskargument; that's now centralised throughcms_media_disk()to keep the disk authority in one place.MediaController::applyFilter()forhas_variantsqueried a non-existentvariantscolumn β the filter never matched anything. Now queries the actualhas_variantsboolean column.MediaResourcealways returnednullfor thevariantsfield because it read$this->variants(a non-existent property) instead ofmeta['variants']. API consumers now get the variant URLs they expect.- Replacing a media file in the Filament edit page left stale variant blobs on disk and kept
meta['variants']pointing at the old image, so subsequentgetVariantUrl('thumbnail')calls returned the wrong image (or 404'd once anything else cleaned them). The replacement flow now deletes old variants, resetshas_variants/optimized_at, and dispatchesOptimizeMediaJobto mirror the create flow. config/tallcms.phpno longer ships a'media'block in the standalone scaffold β it was shadowing the package'smedia.optimization.*sub-tree because Spatie'smergeConfigFromonly merges the first level. The package config defines'disk' => env('TALLCMS_MEDIA_DISK')directly, so standalone hosts inherit the env-var path through the merge.
Tests
PR #71 added 600+ lines of new coverage spanning MediaController, the disk helper, and the model β including dedicated cases for the has_variants filter (true/false) and resource variants inclusion/omission paths.
Upgrading
No code changes required. To opt into a custom media disk, set TALLCMS_MEDIA_DISK in your .env. Existing installs without the env var continue to use the existing auto-detect path.
Pull request
- #71 β Add configurable media disk via TALLCMS_MEDIA_DISK (@jakublacko)