Skip to content

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().

<?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'];
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.

Public share links render a standalone ~6 KB gallery with zero ProcessWire Admin scripts.

Eight Security Guarantees (ShareService & ShareEndpoint)

Section titled “Eight Security Guarantees (ShareService & ShareEndpoint)”
  1. One-Time Raw Token Display: Raw 256-bit random tokens are shown only once when created or regenerated. entries_tbl_media_shares stores exclusively hash('sha256', $rawToken).
  2. Uniform 404 Responses: Invalid, expired, revoked, or quota-exhausted links return identical 404 responses with X-Robots-Tag: noindex, nofollow, Referrer-Policy: no-referrer, X-Content-Type-Options: nosniff, and Cache-Control: private, no-store.
  3. Private Vault & Embargo Isolation: Creating a share for any private or hidden (hidden_from_library = 1 or owner != 'site') asset throws WirePermissionException. Embargoed assets are also excluded automatically.
  4. Password Unlock Throttling & CSRF: Password-protected galleries require a valid POST ProcessWire CSRF token (media_share) and enforce per-IP + token rate limiting via WireCache (share_rate_limit, default 10 attempts per 15 minutes).
  5. Atomic Download Quotas: max_downloads decrements atomically via TableStore::atomicAdjust() so concurrent requests cannot exceed the limit.
  6. 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 bounded 1200px share_preview variations for raster images instead of raw masters.
  7. Bounded Streaming ZIP: Folder ZIP downloads enforce share_max_zip_files (default 200) and share_max_zip_bytes (default 1 GiB) caps and stream directly from disk without buffering full archives in PHP memory.
  8. Zero Admin Leakage: Public share pages never expose internal ProcessWire paths, user accounts, or admin JavaScript bundles.

Next steps