Shareable Galleries
Users with the media-share (or media-admin) permission can create external shareable links for any public asset, folder, or collection under Setup > Media > Shares or programmatically through $media->shares()->createShare().
Creating a Share Link in PHP
Section titled “Creating a Share Link in PHP”<?php
declare(strict_types=1);
namespace ProcessWire;
$media = $this->wire()->media;
$result = $media->shares()->createShare('collection', $folderId, [ 'title' => 'Aegean Voyages 2026 Press Kit', 'expires_at' => '+14 days', 'password' => 'aegean2026', 'max_downloads' => 50, 'allow_download' => true, 'allow_original' => false,]);
// Raw 256-bit token is returned only once at creation or regeneration:$shareUrl = $this->wire()->config->urls->root . '_media/share/' . $result['token'];Standalone Public Gallery (dist/MediaShare.js)
Section titled “Standalone Public Gallery (dist/MediaShare.js)”Visitors opening /_media/share/{token} receive a fast, WCAG 2.1 AA public gallery powered by an isolated ~6 KB dist/MediaShare.js bundle with zero admin scripts and zero ReactWorkspaceRuntime leakage.
Eight Security Guarantees (ShareService & ShareEndpoint)
Section titled “Eight Security Guarantees (ShareService & ShareEndpoint)”- One-Time Raw Token Display: Raw 256-bit random tokens are shown only once when created or regenerated.
entries_tbl_media_sharesstores exclusivelyhash('sha256', $rawToken). - Uniform
404Responses: Invalid, expired, revoked, or quota-exhausted links return identical404responses withX-Robots-Tag: noindex, nofollow,Referrer-Policy: no-referrer,X-Content-Type-Options: nosniff, andCache-Control: private, no-store. - Private Vault & Embargo Isolation: Creating a share for any private or hidden (
hidden_from_library = 1orowner != 'site') asset throwsWirePermissionException. Embargoed assets are also excluded automatically. - Password Unlock Throttling & CSRF: Password-protected galleries require a valid
POSTProcessWire CSRF token (media_share) and enforce per-IP + token rate limiting viaWireCache(share_rate_limit, default10attempts per 15 minutes). - Atomic Download Quotas:
max_downloadsdecrements atomically viaTableStore::atomicAdjust()so concurrent requests cannot exceed the limit. - Preview-Only Mode (
allow_original = false): When original master downloads are disabled, both single-asset downloads (/_media/share/{token}/asset/{assetId}) and folder ZIP archives (/_media/share/{token}/zip) stream bounded1200pxshare_previewvariations for raster images instead of raw masters. - Bounded Streaming ZIP: Folder ZIP downloads enforce
share_max_zip_files(default200) andshare_max_zip_bytes(default1 GiB) caps and stream directly from disk without buffering full archives in PHP memory. - Zero Admin Leakage: Public share pages never expose internal ProcessWire paths, user accounts, or admin JavaScript bundles.