Private S3-backed image uploads, galleries, and reusable image BBCode for phpBB. https://www.phpbb.com/community/viewtopic.php?t=2675536
  • PHP 79.8%
  • HTML 9.1%
  • JavaScript 6.7%
  • CSS 2.5%
  • Shell 1.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-29 15:52:29 +00:00
acp Add ACP configuration and image administration 2026-07-28 15:45:41 +00:00
adm/style Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
config Add optional ImageMagick processing for gallery uploads 2026-11-24 07:02:57 +00:00
controller Add optional ImageMagick processing for gallery uploads 2026-11-24 07:02:57 +00:00
core Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
event Add personal image management page 2026-07-28 15:33:48 +00:00
language Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
migrations Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
repository Add ACP configuration and image administration 2026-07-28 15:45:41 +00:00
s3 Harden image delivery boundaries 2026-07-29 08:29:41 +00:00
service Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
styles/all Add optional ImageMagick processing for gallery uploads 2026-11-24 07:02:57 +00:00
tests Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
.gitattributes Polish the 1.0 release and documentation 2026-07-28 15:59:51 +00:00
.gitignore Add release ZIP build script 2026-07-28 16:51:30 +00:00
build-release.sh Add release ZIP build script 2026-07-28 16:51:30 +00:00
CHANGELOG.md v1.4.1 2026-11-29 15:52:29 +00:00
composer.json v1.4.1 2026-11-29 15:52:29 +00:00
ext.php Add safe SVG TIFF and AVIF uploads 2026-07-28 16:24:58 +00:00
phpunit.xml.dist Build S3-backed image storage foundation 2026-07-28 15:23:22 +00:00
README.md Add an option to preserve indexed PNG uploads 2026-11-29 15:45:33 +00:00
SECURITY.md Polish the 1.0 release and documentation 2026-07-28 15:59:51 +00:00

Image Provider for phpBB

Image Provider gives registered phpBB users a reusable, S3-backed image gallery in the post and topic editor.

Users can upload one or more images from the editor toolbar or by drag and drop, follow per-file upload progress, browse recent images in a Masonry-style gallery, and insert the selected image as [img] BBCode at the current cursor position. A separate My images page supports uploads and deletion, while administrators can configure storage and manage every user’s images from the ACP.

Remote bucket URLs and object keys are never sent to the browser. Public forum image URLs contain a random 128-bit identifier and are served by a phpBB proxy with browser caching, conditional requests, byte ranges, and a size-bounded least-recently-used disk cache.

Requirements

  • phpBB 3.3
  • PHP 7.2 or newer, on a version supported by the installed phpBB release
  • PHP cURL, DOM, Fileinfo, and Mbstring extensions
  • An S3-compatible bucket and credentials with object read, write, and delete access
  • A writable phpBB store/ directory

Install

  1. Copy the extension to phpBB/ext/bobmaster/imageprovider. The directory name is imageprovider, without a hyphen.
  2. In the ACP, open Customise → Manage extensions and enable Image Provider.
  3. Open Extensions → Image Provider → Settings.
  4. Enter the S3-compatible endpoint, bucket, signing region, access key, and secret.
  5. Use Test connection. The test creates a random canary object, reads its metadata and contents, then deletes it.
  6. Save the settings.

S3 permissions

The credentials need GetObject, PutObject, and DeleteObject for the configured prefix. S3 handles HEAD through the object-read permission. ListBucket is not required.

An AWS-style policy for the default image-provider/ prefix is:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject"
      ],
      "Resource": "arn:aws:s3:::YOUR_BUCKET/image-provider/*"
    }
  ]
}

Keep the bucket private. Browser CORS access to the bucket is not needed because browsers only contact the forum proxy.

Use virtual-host style when the provider supports bucket.endpoint/key. Enable path style when the provider instead requires endpoint/bucket/key. Cloudflare R2 uses the account endpoint, region auto, and normally virtual-host style.

Configuration

The ACP provides:

  • a global upload/gallery switch;
  • endpoint, bucket, region, access key, secret, request style, and object prefix;
  • maximum upload size from 1 to 100 MiB;
  • an optional per-user quota;
  • optional ImageMagick resizing and compression before storage;
  • a backend disk-cache limit;
  • a browser/shared-cache lifetime from 0 to 365 days;
  • an infinite-scroll page size from 5 to 50 images;
  • an ACP image-manager page size from 5 to 100 rows.

The secret is stored in phpBB’s text configuration table and is never rendered back into the ACP. Leaving its field blank preserves the current value.

These environment variables override the corresponding database values at runtime:

S3_ENDPOINT
S3_BUCKET
S3_REGION
S3_ACCESS_KEY_ID
S3_SECRET_ACCESS_KEY
S3_FORCE_PATH_STYLE

The object-key prefix remains an ACP setting. Provision the same environment values to both web and CLI processes when environment overrides are used.

ImageMagick processing

Install ImageMagick and enable the PHP imagick extension on the forum’s web server. Under Extensions → Image Provider → Settings → Image processing, enable processing. The suggested settings fit images within 2560 × 1440 pixels, re-encode images above 2 MiB even when they already fit, and use quality 76 for JPEG and WebP. A threshold of 0 turns off size-triggered recompression. Resizing and selected WebP conversions still run.

Image Provider preserves aspect ratio and avoids enlarging small images. Processing applies to still JPEG, PNG, and WebP uploads from both the editor and My images. PNG uses lossless compression. Animated images and other supported formats follow their usual upload path. When an image only needs compression, Image Provider uses the result if it is smaller. The compression threshold triggers processing and the result may still exceed that threshold. The original upload must fit within the maximum upload size. If resizing or conversion produces a file over that limit, Image Provider stores the validated original. The per-user quota counts stored bytes.

Files that need a codec missing from the server’s ImageMagick build are uploaded unchanged. This also applies to 16-bit PNGs on 8-bit ImageMagick builds to preserve their color precision. ImageMagick processing accepts source images up to 50 megapixels. The web server’s ImageMagick resource policy also applies.

Under Convert to WebP, select JPEG, PNG, or Other still images (AVIF, GIF, TIFF). The options default to off and require ImageMagick with WebP encoding support. Selected still images are converted at the configured quality even below the compression threshold. Resizing uses the configured dimensions and WebP’s limit of 16,383 pixels per side. WebP preserves transparency and can use lossy color compression. Animated and multipage files keep their original format, SVG keeps its normal sanitization path, and existing WebP uploads follow the usual resize and compression settings.

Preserve indexed PNGs is off by default. When enabled, palette-based PNGs keep their original bytes, dimensions, and format. This skips resizing, compression, and WebP conversion. Full-color PNGs still follow the configured processing options.

Post attachments

With phpBB attachments enabled, dropping files onto the post editor sends supported images to Image Gallery and the other files to phpBB’s Attachments panel. phpBB handles drops that include folders, including any files dropped alongside them. Users can also explicitly use either upload button. ZIP, MP3, and other attachments must be allowed by phpBB’s attachment extension groups and forum permissions.

Access and deletion behavior

  • Guests and bots cannot use the gallery or management API.
  • Registered users can browse and manage their own existing images.
  • Users marked by phpBB as newly registered cannot upload until phpBB clears their user_new status.
  • API mutations use phpBB link hashes, and users can only delete their own rows.
  • ACP settings require acl_a_board; ACP image management requires acl_a_user.
  • Deletion removes the S3 object first. Only after S3 confirms deletion, or reports that the object is already absent, does the extension remove the database row and local cache entry.

Deleting an image breaks posts that reference its proxy URL. Browsers or shared caches may retain a previously fetched copy until the configured browser-cache lifetime expires.

Purging the extension removes its database table and settings but does not enumerate and delete objects left in the bucket. Remove images through the user or ACP interface first, or clean the configured prefix with the storage provider before purging.

Proxy and cache behavior

The proxy:

  • returns the validated stored MIME type with X-Content-Type-Options: nosniff;
  • applies a restrictive sandbox Content Security Policy to SVG responses;
  • supports ETag, Last-Modified, If-None-Match, and range responses;
  • sends public max-age, s-maxage, and immutable directives;
  • stores fetched objects under phpBB/store/image_provider_cache/;
  • updates cache-file modification time on access and evicts the least recently used files when the configured byte limit is exceeded.

The backend cache is local to each phpBB node. In a multi-node installation, the configured limit applies independently to every node.

Supported images

JPEG, PNG, GIF, WebP, TIFF, SVG, and AVIF are accepted. The server verifies the actual file format and image dimensions rather than trusting the filename or browser-provided content type. SVG files are parsed and stripped of scripts, external resources, event handlers, animation, and inline styles before upload. Object names are generated from random identifiers and never from the original filename.

TIFF display support varies by browser. The gallery shows a clear fallback when a browser cannot preview a valid TIFF; the original file remains available through the forum proxy and can still be inserted as image BBCode.

Languages

  • English
  • Simplified Chinese (zh_cmn_hans)
  • Traditional Chinese (zh_cmn_hant)

Development and tests

Run the test suite from the extension root with a PHPUnit 9 runner:

phpunit --configuration phpunit.xml.dist

The suite covers S3 request construction and signing, storage configuration, SVG sanitization, AVIF/TIFF format handling, LRU eviction, access rules, editor/manager/ACP integration assets, and translation key and placeholder parity.

Security

Report vulnerabilities privately to the extension maintainer. Do not include live S3 credentials, phpBB passwords, session IDs, or private object contents in a public issue.

License

GNU General Public License v2.0 only.