wintercms / wintercms/winter

Add support for Media Library metadata

Open
#16 4 comments 0 reactions 2 assignees View on GitHub

@bennothommo is already working on this.

Since Feb 2, 2022.

high priority
Dominant language
PHP
Stars
1.5k
Forks
246
Avg merge
19h 2m
Merged PRs (30d)
7

Description

Media Library Metadata

General:

  • This is a progressive enhancement that will live in the System module. Simply check if app::hasDatabase() or something similar before registering event listeners
  • Media Manager should have integrations with the Form widget to simply extending it
  • Perhaps handle https://github.com/rainlab/translate-plugin/issues/192 as a part of this

Schema:

Table Name: media_library_items
id // To simplify other people's relationships to Media Items
disk // To distinguish between multiple files stored on different disks
path // The path to the media item
metadata // JSON stored metadata.
timestamps?

Model:

Name: MediaItem
Interface:
MediaItem::fromPath($path, $disk = $defaultDisk) // Gets the Media metadata for the specified path
- Provide method to load metadata directly from the identifier passed that would override the stored metadata. I.e. Path could be either a string or an array containing overriding metadata.
- Perhaps have getAttribute() attempt to pull unknown attributes from the ->metadata->$attribute?
- Perhaps have setAttribute() do the same?
- Take inspiration from https://github.com/kodeine/laravel-meta. 

Interactions:

  1. Media Metadata integration will listen to the media events and update the DB reference to the path on the appropriate events
  2. Attempting to access a MediaItem that doesn't exist in the DB yet will create it in the DB (perhaps only if it exists in the disk?)
  3. Perhaps integrate File Interface for using in the file model and Media Item model?
  4. Twig interface should be {{ media(path, optionalDisk).mediaItemPropertyOrMethod }}

Perhaps take some extensibility inspirations from https://github.com/ctf0/Laravel-Media-Manager

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.