Yes, there are several packages available that can help you manage image assets, create collections, order, and tag them. One such package is Spatie's Media Library. It provides a simple and flexible way to manage files and images in Laravel applications.
Here's how you can use it to achieve the requirements mentioned in the question:
- Upload image assets to AWS (or Google Cloud or something similar like Cloudinary,...).
Spatie's Media Library supports multiple drivers for storing files, including local disk, Amazon S3, Google Cloud Storage, and more. You can configure the driver of your choice in the config/filesystems.php file.
- Ability to create a collection (album) of images.
You can create a collection of images using the addMedia() method of the HasMedia trait. For example:
$user->addMedia($pathToFile)->toMediaCollection('avatars');
This will add the file at $pathToFile to the avatars collection of the $user model.
- Ability to create a hierarchy of images (a collection of a collection), eg. folder structure.
Spatie's Media Library supports nested collections, which can be used to create a hierarchy of images. For example:
$user->addMedia($pathToFile)->toMediaCollection('posts.images');
This will add the file at $pathToFile to the images collection of the posts collection of the $user model.
- Ability to re-order images in a collection.
You can use the setOrder() method to set the order of media items in a collection. For example:
$user->getMedia('avatars')->setOrder(['id' => [3, 1, 2]]);
This will set the order of media items in the avatars collection of the $user model to 3, 1, 2.
- Ability to add tags to images.
Spatie's Media Library supports adding tags to media items. You can use the addMediaTags() method to add tags to a media item. For example:
$user->addMedia($pathToFile)->toMediaCollection('avatars')->addMediaTags(['male', 'young']);
This will add the file at $pathToFile to the avatars collection of the $user model and add the tags male and young to it.
You can find more information about Spatie's Media Library in the official documentation: https://spatie.be/docs/laravel-medialibrary/v9/introduction