Flarum ships with no built-in attachment system. Everything related to images, file uploads, thumbnails, and remote storage is delivered by the community extension FoF Upload (fof/upload), which plugs into Flarum's Flysystem-based storage layer and the Intervention Image library. That means media optimization on a Flarum forum is really a conversation about three things working together: what the extension is configured to do in the admin panel, what PHP imaging support your hosting account actually loads, and how finished files are served to visitors. On Managed Cloud Shared Hosting you cannot recompile PHP or touch server-wide daemons, but every lever that matters for Flarum media lives either in the admin dashboard, in .user.ini, or in .htaccess — all account-level.
The most common complaints — oversized originals eating disk quota, slow-loading image-heavy discussions, layout shift as pictures lazy-load, and thumbnails that simply never appear — trace back to misconfiguration or to a missing PHP extension rather than to Flarum itself. The sections below walk through tuning the extension, verifying the imaging stack your plan provides, controlling upload size at the PHP layer, and offloading delivery to a CDN or object storage where the extension genuinely supports it.
Configuring thumbnails and WebP output in FoF Upload
Enable FoF Upload under Admin → Extensions, then open the dedicated Upload tab that appears in the left admin sidebar. The thumbnail feature is the single biggest bandwidth win for a busy forum. When it is switched on, FoF Upload keeps the original file untouched but generates a downscaled copy at upload time, scaled to a configurable maximum width (the default is 1000 px). The Image Preview template then displays that smaller copy and wraps it in a link to the full-resolution original, so clicking an image opens the untouched file in a new tab.
By default those thumbnails are encoded as WebP, which the extension documents as roughly 30% smaller than an equivalent-quality JPEG. If you disable WebP, thumbnails are written in the source format instead. For a discussion board where members routinely paste phone screenshots and camera photos, leaving WebP enabled and setting a sensible maximum width is the difference between a thread that renders instantly and one that drags multi-megabyte JPEGs across the wire.
Two settings on the same page deserve attention. First, the allowed MIME type regex. New installs seed a safe pattern similar to ^image\/(jpeg|png|gif|webp|avif|bmp|tiff|svg\+xml)$. You can add or remove formats here, but avoid broad wildcards like ^image\/.* — older versions used that and it is considered insecure. Second, dimension storage: FoF Upload records width and height for JPEG, PNG, and GIF files so the browser can reserve space and avoid layout shift while images lazy-load.
If you enabled thumbnails after the forum already had content, existing images have no thumbnail yet. The backfill routine handles that, but it is a console command. On shared hosting you reach it through the Cron Jobs area of cPanel or DirectAdmin rather than an interactive shell. A one-off scheduled command pointed at your document root works:
cd /home/USERNAME/public_html && /usr/local/bin/php flarum fof:upload:backfill-thumbnailsThe command walks each JPEG, PNG, and GIF, scales it to your configured width, encodes it as WebP (or the original format if WebP is off), and writes the thumbnail alongside the original. It skips images that already have one, so it is safe to leave scheduled or to remove once it has finished. A companion command, php flarum fof:upload:backfill-dimensions, fills in missing width/height values in batches — add --dry-run first to see how many rows would be touched.
Verifying the PHP imaging stack and conversion support
WebP and AVIF output only works if your selected PHP version actually loads an imaging library capable of encoding those formats. Intervention Image, which FoF Upload uses, sits on top of either GD or Imagick. If thumbnails silently refuse to generate, or you see exceptions about an unsupported encoder in the forum's error log, the cause is almost always a missing extension on the PHP version Flarum is running under.
Check this through the control panel rather than guessing. In cPanel Jupiter open Select PHP Version → Extensions (the PHP Selector), and in DirectAdmin Evolution use Select PHP Version under the PHP settings. Confirm that gd or imagick is ticked, along with fileinfo and exif. The fileinfo extension matters for security as well as processing: FoF Upload identifies every upload twice and rejects files whose declared and detected formats disagree, and that second check uses libmagic via fileinfo.
AVIF encoding needs a reasonably modern GD or Imagick build; many shared PHP 8.1+ stacks include it, but not all. The reliable way to see what you have is a one-line diagnostic file placed in your document root through File Manager:
<?php phpinfo();Load it in a browser, search the page for gd and imagick, and confirm WebP and AVIF appear under supported formats. Delete the file immediately afterward — leaving phpinfo() reachable exposes environment detail you do not want public. If AVIF is absent, keep thumbnails on WebP; it has far wider encoder availability and still delivers most of the bandwidth benefit. Whenever you change the PHP version or toggle an extension, clear Flarum's cache afterward (Admin → Dashboard → Clear Cache) so the new capabilities register.
Controlling upload size and storage footprint
Flarum enforces its own per-file size in the Upload tab, but that limit is meaningless if PHP rejects the request first. Two PHP directives gate every upload: upload_max_filesize and post_max_size. On shared hosting you set these per account with a .user.ini file in your document root — never by editing php.ini or my.cnf, which you do not have access to. A typical forum that accepts photos but not large archives might use:
upload_max_filesize = 12M
post_max_size = 16M
memory_limit = 256M
max_execution_time = 120Keep post_max_size larger than upload_max_filesize so multi-file drag-and-drop requests are not truncated, and keep memory_limit generous because resizing and WebP encoding large images is memory-hungry — an under-provisioned limit shows up as blank thumbnails and fatal errors in the log. Changes to .user.ini are picked up after the cache TTL (often a few minutes) rather than instantly. Many cPanel plans also expose upload_max_filesize directly in the Select PHP Version → Options screen, which writes the same value for you.
Storage quota is the other half of the equation. Because FoF Upload keeps every original intact, an active forum accumulates unreferenced files when posts are edited or deleted. The extension's mapping and cleanup routine identifies files no longer used in any post and removes stale ones, which you can schedule as a Cron Job:
cd /home/USERNAME/public_html && /usr/local/bin/php flarum fof:upload --map --cleanup --cleanup-before="last year" --forceRun the mapping step on its own first so you understand what it finds before anything is deleted. This same disk-discipline thinking applies to any attachment-based platform; our MyBB media and storage guide covers a parallel approach for a different forum engine.
CDN delivery and object storage offload
Local storage works out of the box, but a forum that serves heavy image traffic from a single shared account benefits from pushing delivery closer to visitors. FoF Upload supports Amazon S3 and S3-compatible providers — Cloudflare R2, Backblaze B2, DigitalOcean Spaces, MinIO — plus Qiniu. These adapters are not bundled; the provider package must be present before the option even appears under Admin → Upload → Storage. The S3 family requires league/flysystem-aws-s3-v3, which is normally added with Composer from your Flarum directory. If your plan does not expose Composer, this is a reasonable item to request from support rather than attempting server-level changes.
Once the adapter is installed and configured with your bucket and credentials, FoF Upload writes both originals and thumbnails to that backend, and it derives the public URL from the live storage hostname at render time. The practical upside is that changing your CDN domain later is reflected automatically without reprocessing any files — the stored path stays the same while the hostname in front of it is recomputed. Point your object-storage bucket behind a CDN hostname and your forum's media is cached at the edge with no change to the posts themselves.
If full object storage is more than you need, a lighter approach keeps files local while letting a CDN cache them. Set long cache headers on static media so a proxy CDN caches aggressively. In an .htaccess file within the directory that holds your uploads, LiteSpeed honors standard expiry rules:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/avif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(webp|avif|jpe?g|png|gif)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>With those headers in place, LiteSpeed Cache and any upstream CDN can hold media at the edge for a year, cutting origin requests dramatically. Combined with WebP thumbnails, sensible PHP upload limits, and periodic cleanup, these account-level changes keep a Flarum forum fast and within quota without ever needing root access.