Tutorials

XenForo Image Optimization: Shrink Uploads, Keep Quality

Set file size and dimension limits in the Admin CP, use small thread thumbnails and offload files when the disk fills up. Steps for XenForo 2.2 and 2.3.

D.C Style · 6 min read
Share on X
A large photo shrinking into a small one beside folders and a cloud
On this page

XenForo image optimization starts in the Admin CP. Open Setup > Options > Attachments and set a maximum file size and maximum image dimensions. Then use small thread thumbnails in lists, and move files off your server if disk space runs low.

This guide is for owners of XenForo 2.2 and 2.3 forums. You don't need to be a developer. Each step shows the built-in way first, then where an add-on saves you work. One note: the free Thumbnail add-on 1.1.0 needs XenForo 2.3 or later. The built-in steps and the Google Drive add-on (2.2.0 or later) also cover 2.2.

The quick answer: limit image size and dimensions in the Admin CP

Two settings do most of the work. Both sit in the Attachments options group:

  1. Open Admin CP > Setup > Options > Attachments.
  2. Set the maximum attachment file size, in KB.
  3. Set the maximum attachment image dimensions, width by height.
  4. Save.

Then check the thumbnails and, if disk space is tight, look at offloading. The sections below explain each step.

Note:
Option names come from forum members' posts, not the official manual. The wording on your screen may differ a little.

Why big images slow your forum down

A phone photo can be several megabytes. Every member who opens that thread has to download it. Pages load slower, mobile visitors wait longer and your server sends more data.

The files also pile up. Attachments are stored on your server's disk, so a busy forum can fill it faster than you expect. Smaller uploads and smaller previews fix both problems.

Set attachment size, dimension and extension limits

File size limit

The file size option is your XenForo image size limit. It is measured in KB. It is also capped by your server's PHP settings, so raising it in XenForo won't help if PHP allows less. Members discuss this in this XenForo community thread.

Dimension limit

There is no separate width or height option. The width and height are two boxes in one dimensions option. Larger images are reduced to fit.

Members in one thread use values such as 800×600 or 1000×1000 with file sizes of 8,000 to 12,000 KB. That lets phone photos upload and then get downsized, instead of being rejected.

An old XenForo 1.5 thread says uploads are resized to fit the limits. One test there turned a 7.13 MB photo into about 183 KB. That thread is old, so try a test upload on your own 2.2 or 2.3 forum and check the result.

What these limits don't do

The settings apply to new uploads. They don't shrink images already on your forum. To compress XenForo attachments that are already stored, community tools such as Image Size Optimizer Tool exist. XenForo 2.3 also appears to have a command-line optimization for existing images. The exact command isn't confirmed here, so check the manual before you run anything.

Tip:
Back up your database and attachment files before you process existing images.

Check how XenForo creates thumbnails and avatars

XenForo makes small previews of image attachments. These are your XenForo attachment thumbnails. According to a moderator in an old thread, their dimensions live in the same Attachments options group. That thread is old, so confirm the option on your 2.2 or 2.3 forum.

GD or Imagick

XenForo can use either of two image libraries. GD is built in. Imagick is optional. A XenForo reply quoted in the community says GD is fine, and that Imagick's main advantage is resizing GIFs while keeping the animation. Another member prefers Imagick when it is available. You can read both views in this thread.

For most forums, whatever your host has set up is fine. Ask your host if you want Imagick enabled for animated GIFs.

Use thread thumbnails instead of full-size images in lists

Thread lists are where many forums waste bandwidth. If a list shows pictures, make sure it shows small ones, not full-size originals.

The free Thumbnail add-on adds a visual preview to supported forum lists, widgets and search results. It can use an image from the first post, a supported video thumbnail, a poster, an author avatar or your default image. You set the order of those sources in the Admin CP.

Version 1.1.0 can also generate cards for text-only threads. A card can show the thread title, author, publication date and time, forum name, board name and your own text. Thumbnail 1.1.0 needs XenForo 2.3 or later.

Setup is covered step by step in Set up Thumbnail, so it isn't repeated here. Note that a fresh install doesn't select any forums for you. You pick them in the options.

Move attachment files off the server when disk space runs low

Limits stop the growth. They don't free space already used. When the disk is nearly full, the manual route is to move the attachment folder to bigger storage, or upgrade your hosting plan. Both take planning and some downtime.

The other route is offloading. Google Drive Attachments replaces local attachment storage with Google Drive. New uploads go straight to Drive. The product page describes migrating existing attachments with one click, and full files and thumbnails move too.

It offers two modes. Direct mode sends uploads straight to Drive. Local cache mode writes to your server first, then moves files to Drive on a schedule and deletes the local copy.

Some details that matter on a big forum:

  • Migration progress is logged, so it can resume after an interruption.
  • An extension filter lets you send only certain file types to Drive.
  • The command-line migration has a --cleanup-local option. It runs as a separate pass, so you can reclaim disk after you have checked the transfer.

It needs XenForo 2.2.0 or later. It adds a Google Cloud setup step, which the guide Set up Google Drive Attachments walks through. For the wider picture, read free up XenForo disk space by moving attachments off the server.

What to check after you change the limits

  1. Upload a large photo as a normal member. Confirm it is accepted and comes out smaller.
  2. Check that the file size limit isn't blocked by PHP limits on your server.
  3. Open a thread with images on a phone and look at how fast it loads.
  4. Look at thread lists and make sure previews show small images.
  5. Watch your disk use over the next few weeks.

What to do next

Start with the two Attachments options and a test upload. Add thread thumbnails if your lists feel heavy and you run XenForo 2.3. Consider offloading only if disk space is the real problem. More how-to guides are in our Tutorials category.

Sources