Skip to content

v4.4.2 - Configurable media disk + media library bug fixes

Choose a tag to compare

@tallcms tallcms released this 30 Apr 03:55
· 33 commits to main since this release

πŸ™ 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_DISK lets installs route media to any filesystem disk defined in config/filesystems.php (custom-named S3 buckets, R2, local, etc.) instead of TallCMS's auto-detection between s3 and public.
  • 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 writing width/height as top-level columns, but those aren't $fillable β€” and the model reads them from meta['width']/meta['height'] via accessors. Dimensions now persist correctly.
  • MediaController::destroy() had a dead manual variant cleanup loop that read a non-existent variants column. Removed; the model's deleting hook already handles file + variant cleanup via ImageOptimizer::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-supplied disk argument; that's now centralised through cms_media_disk() to keep the disk authority in one place.
  • MediaController::applyFilter() for has_variants queried a non-existent variants column β€” the filter never matched anything. Now queries the actual has_variants boolean column.
  • MediaResource always returned null for the variants field because it read $this->variants (a non-existent property) instead of meta['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 subsequent getVariantUrl('thumbnail') calls returned the wrong image (or 404'd once anything else cleaned them). The replacement flow now deletes old variants, resets has_variants / optimized_at, and dispatches OptimizeMediaJob to mirror the create flow.
  • config/tallcms.php no longer ships a 'media' block in the standalone scaffold β€” it was shadowing the package's media.optimization.* sub-tree because Spatie's mergeConfigFrom only 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)