Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Assetlibrary Laravel Package

thinktomorrow/assetlibrary

A Laravel package for managing uploaded assets and media files in one central library, making it easy to store, organize, and retrieve images and other files across your application.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Upgrade to 0.7.4 in a branch and run the package test suite plus your application’s image/asset tests.
  • Look first at the Asset API for getWidth() and getHeight(), and at deleteAsset() to confirm its return/exception behavior in your integration.
  • First smoke test:
$asset = Asset::findOrFail($assetId);

$width = $asset->getWidth();
$height = $asset->getHeight();

$asset->deleteAsset();
  • First practical use case: use getWidth() / getHeight() when rendering images or validating aspect ratios instead of calling PHP image functions directly. Use deleteAsset() in cleanup jobs where the asset may already be gone.

Implementation Patterns

  • Prefer the package getters over direct filesystem/image-library calls:
$asset = Asset::findOrFail($id);

$ratio = $asset->getHeight() > 0
    ? $asset->getWidth() / $asset->getHeight()
    : null;
  • Use dimensions in validation or layout decisions:
$validator->after(function ($validator) use ($asset) {
    if ($asset->getWidth() < 1200) {
        $validator->errors()->add('asset', 'Image must be at least 1200px wide.');
    }
});
  • Make deletion idempotent in jobs and cleanup commands. With the new exists check in deleteAsset(), code can call it without a separate pre-check, but still handle the package’s documented return value or exceptions:
foreach ($staleAssets as $asset) {
    $asset->deleteAsset();
}
  • If your application stores width/height columns for performance, add a backfill/sync step after upgrading because 0.7.4 changes dimension calculations.
  • When rendering responsive media, read dimensions once per asset and reuse them in the request/loop rather than calling getters repeatedly for the same asset.

Gotchas and Tips

  • The dimension calculation change is the main upgrade risk. Existing images may now report different width/height values. Add regression coverage for landscape, portrait, square, and EXIF-oriented images.
  • Audit any code that depends on exact dimensions: thumbnail sizing, aspect-ratio validation, CSS layout assumptions, and stored metadata.
  • Verify getWidth() / getHeight() behavior for unsupported or unusual assets such as SVG, PDF, remote streams, or missing files. Guard against null, 0, or package-specific exceptions.
  • The new exists check in deleteAsset() makes deletion safer for repeatable jobs, but do not use it as a substitute for monitoring missing assets. Log or report skipped deletions if missing files indicate a data issue.
  • Clear any application-level caches of asset metadata after upgrading, especially if dimensions are cached in Redis, response caches, or computed columns.
  • If the package exposes image drivers or dimension resolvers, confirm your custom implementation still matches the new calculation path. Add a focused test around your custom driver if one is configured.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk