Skip to main content

splent_feature_media

The media feature of a SPLENT product line: a media library to upload and manage files, the analogue of WordPress's Media Library, with a public gallery the product may show or keep to itself.

A SPLENT feature is a Python package that a product composes with others: its models, routes, services, templates and hooks are registered when the product starts. What this feature provides and requires is listed in the [tool.splent.contract] section of pyproject.toml, which splent feature:contract --write keeps in sync with the source. What it reads from the environment, and its defaults, is [tool.splent.config].

Use it in a product

splent feature:add splent_feature_media

Configuration

Declared in [tool.splent.config], with their types in [tool.splent.config_schema]. The runtime ones are also fields of the settings panel (register_settings("media", "Media", ...)), stored as media_<field> (media_public_gallery for MEDIA_PUBLIC_GALLERY), and the panel wins; param('media', 'MEDIA_PUBLIC_GALLERY') reads whichever is in force.

Key Type Bind Default What it does
MEDIA_PUBLIC_GALLERY bool runtime true The gallery page at /media, browsable by anyone. Off answers 404, so visitors cannot enumerate the library
MEDIA_NAV_LABEL text derivation empty The main-nav label of the gallery. Empty keeps it out of the nav. Not in the panel: the nav entry is registered at start, so a panel value would change nothing until a restart
MEDIA_HOME_COUNT int, at least 0 runtime 0 The latest public photos the home page shows, in its home.section slot (order 40). Zero hides the section
MEDIA_GALLERY_VIEW enum: grid, mosaic runtime grid How the gallery opens. A visitor may switch, and the browser remembers it
MEDIA_GALLERY_PAGE_SIZE int, at least 1 runtime 48 Photos loaded at once as the visitor scrolls
MEDIA_SLIDESHOW_SECONDS int, at least 1 runtime 4 Seconds per photo in the slideshow
MEDIA_UPLOAD_IN_GALLERY bool runtime true Whether the upload form ticks "show in the public gallery"
MEDIA_MAX_UPLOAD_SIZE size deploy 100M The largest file the library takes, as 100M, 1G or a number of bytes. 0 means no limit
PROTECTED_UPLOADS_DIR str deploy empty Where files that are not public live. Empty is the framework's default; in production, the mount target of a named volume
PROTECTED_FILES_ACCEL_PREFIX str, /.+ deploy empty The internal nginx prefix a protected file is handed over with (X-Accel-Redirect). Empty streams it through Python, which is right without a proxy in front

A library takes files bigger than a form (slides, recordings, scanned course material), so media raises the framework's request cap, MAX_CONTENT_LENGTH, to MEDIA_MAX_UPLOAD_SIZE, and never lowers it. It does so in init_feature, from the resolved app.config, not in inject_config from the environment: the product's value beats a docker/.env merged before the product changed it, and a cap raised from the environment could let through files far bigger than the limit the product set.

The gallery opens its photos in the theme's lightbox, and appends the next page as a slideshow reaches the end (splent:lightbox:end). A product without media can still show a few static images on its home with the theme's SITE_GALLERY.

Frontend

The library's image editor, on an image's detail page (media/admin_detail.html), is Cropper.js: crop, rotate and reset over the preview, and the crop saved as a new media item. Its script is assets/js/cropper.js, which imports Cropper.js and its stylesheet; cropperjs 1.6.2 is an npm dependency in frontend/package.json, locked in frontend/package-lock.json, and nothing of it is vendored. The SPLENT toolchain builds the entry cropper into assets/dist/cropper.bundle.js and assets/dist/cropper.css, which the page loads, and only that page: Cropper's .cropper-* classes are global. The message the editor shows when a crop cannot be saved reaches the script in a data-* attribute, in the page's language. The markup uses the shell's Bootstrap CSS, declared in splent.shell, so product:validate checks the product provides it.

The public gallery's own script and stylesheet (assets/js/gallery.js, assets/css/gallery.css) and the picker's (assets/css/picker.css) are the feature's own code, without a build, served as they are and registered with register_asset.

splent feature:compile media            # build it once, in development mode
splent feature:compile media --watch    # again on every change
splent feature:compile media --verify   # the files match assets/meta/manifest.json
splent feature:npm media outdated       # a newer Cropper.js?

Develop

splent feature:test splent_feature_media
splent feature:contract splent_feature_media

Release

splent feature:release splent_feature_media --dry-run --bump minor
splent feature:release splent_feature_media

The first command rehearses the release, its frontend gates included (the production build, the licences of what the bundle ships and npm audit), and changes nothing. The second publishes it to the git forge and to PyPI, and a PyPI version is permanent.

Metadata

Release files for splent-feature-media 0.13.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for splent-feature-media 0.13.1
File Size Uploaded Provenance Actions
splent_feature_media-0.13.1.tar.gz 68.6 kB Without provenance Details for splent_feature_media-0.13.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for splent-feature-media 0.13.1
File Interpreter ABI Platform Actions
splent_feature_media-0.13.1-py3-none-any.whl Python 3 none any Details for splent_feature_media-0.13.1-py3-none-any.whl

Total release size: 151.0 kB

Release files / splent_feature_media-0.13.1.tar.gz

Download URL splent_feature_media-0.13.1.tar.gz
Size 68.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5b2d23609f5c29dc0790a82bd5d05f72f7a48b9c8cde5a772a618a46e851e874
BLAKE2b-256 checksum
How to use checksums
38e5edb3747c9ffa47f15734a8bf9997dd3e59fecd56c94a50eebc4e59cad90a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release files / splent_feature_media-0.13.1-py3-none-any.whl

Download URL splent_feature_media-0.13.1-py3-none-any.whl
Size 82.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8dfc2cbe85a2bdf437a35f473b36f63a8f912c1f67285d96100d6084dac9b18
BLAKE2b-256 checksum
How to use checksums
6702f53dae636045f0058fd91d6072a5c9b860dc2f61a42f41d2c2422d16d5e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Security for splent-feature-media 0.13.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page