tungsten-media-library
Media library plugin for Tungsten: every image and file of your panel in one place. Upload once, add alt text, see where a file is used, and pick it again from any file field. Like Curator for Filament.
pip install tungsten-media-library
from tungsten import LocalStorage
from tungsten_media_library import MediaLibraryPlugin
panel = Panel(..., storage=LocalStorage("storage", public=True)) # public=True: images show on your website
panel.plugin(MediaLibraryPlugin())
panel.create_tables(engine)
Needs tungsten-admin 0.1.8 or newer.
What you get
- Media library screen: upload many files at once, folders, search, tabs by type (images, documents, videos, audio), alt text, captions and tags.
- Choose from library under every file field of the panel: a grid with search. Image fields show only images.
- Everything in one place: files uploaded anywhere in the panel (like a blog cover) join the library with their real name, type, size and pixel size. Ticket attachments, HR documents and imports stay private.
- Same file twice is stored once.
- Used in: see every blog post, ticket or employee that uses a file. Files in use can't be deleted by mistake.
- Copy link and a ready Markdown line for blog posts.
- Check files finds entries whose file is gone from the disk.
Works with other plugins
- Blog (
tungsten-blog): covers, social images and author photos from the library; posts show in "Used in". - Help desk (
tungsten-tickets): attach library files to replies and notes. - HR (
tungsten-hr): attach library files to employees. - Tags (
tungsten-tags): shared, colored tags and a tag filter. - Quick create (
tungsten-quick-create): "Upload files" in the + New menu. - PWA (
tungsten-pwa): a "Media library" shortcut on the app icon.
None of them is needed.
Options
MediaLibraryPlugin(
capture_uploads=True, # add files uploaded anywhere in the panel
picker=True, # "Choose from library" on every file field
dedupe=True, # same file twice: keep one copy
private_directories=("imports", "tickets", "hr"),
max_size=20480, # kilobytes per file
max_files=20, # files per upload
accepted_file_types=None, # e.g. ["image/*", ".pdf"]
protect_used=True, # don't delete files in use
)
Hooks
media = panel.get_plugin("media")
media.on_media_added("key", lambda db, item: ...)
media.on_media_deleted("key", lambda db, item: ...)
media.track("products", Product, "image", "gallery", label="Product") # count your own file columns
media.add_usage_finder("key", lambda db, item: [{"label": "Page", "title": "Home", "url": "/admin/pages/1"}])
Full guide: https://tungsten.prisminfoways.com/docs/media-library
Try it
pip install -e . -e plugins/media-library -e plugins/blog -e plugins/tickets uvicorn
cd plugins/media-library && uvicorn example:app --reload
Open http://127.0.0.1:8000/admin and sign in with admin@example.com / password.
MIT license.
Metadata
Release files for tungsten-media-library 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tungsten_media_library-0.1.0.tar.gz | 23.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tungsten_media_library-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.0 kB
Release files / tungsten_media_library-0.1.0.tar.gz
| Download URL | tungsten_media_library-0.1.0.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20b86dc5d1b9ceab44d115a154a8f0e7f0616dd95d3adb3a952b017d6b1c7e3f
|
|
BLAKE2b-256 checksum How to use checksums |
c15721fd7bc1fd24a0faf614524bcdabf1ab640ce88490ca974fa5d5c08bb488
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / tungsten_media_library-0.1.0-py3-none-any.whl
| Download URL | tungsten_media_library-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9831d36c75258a231d4d9f6ad36211a2638a450c962a29556e7fc932dd5fb405
|
|
BLAKE2b-256 checksum How to use checksums |
f72d314514a92c90b6a8b70ee42d4bb64d6befd5ce0f5c32ac8cdc3db09133e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|