PHPackages                             huoxin/auto-image-dimensions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. huoxin/auto-image-dimensions

ActiveFlarum-extension[Utility &amp; Helpers](/categories/utility)

huoxin/auto-image-dimensions
============================

Automatically fetches and applies width and height dimensions to Flarum image tags to prevent layout shift (CLS).

1.0.3(1mo ago)04↓60%MITPHPCI passing

Since Jul 8Pushed 1mo agoCompare

[ Source](https://github.com/huoxin233/flarum-ext-auto-image-dimensions)[ Packagist](https://packagist.org/packages/huoxin/auto-image-dimensions)[ RSS](/packages/huoxin-auto-image-dimensions/feed)WikiDiscussions 1.x Synced 1w ago

READMEChangelog (8)Dependencies (10)Versions (10)Used By (0)

Auto Image Dimensions
=====================

[](#auto-image-dimensions)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667) [![Latest Stable Version](https://camo.githubusercontent.com/2385bde136011d2c2b148734aa61c955c18a5d2831c951432c797bfd5a93088e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68756f78696e2f6175746f2d696d6167652d64696d656e73696f6e732e737667)](https://packagist.org/packages/huoxin/auto-image-dimensions) [![Total Downloads](https://camo.githubusercontent.com/fb8f467ff7cdac5a0d28aa024402698f75d49732e5f2bbc170ce5e2aee35656a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68756f78696e2f6175746f2d696d6167652d64696d656e73696f6e732e737667)](https://packagist.org/packages/huoxin/auto-image-dimensions) [![Review](https://camo.githubusercontent.com/6e034c31e887cb3783091c1f6473aa6f4b69a4d65ddeb9509e13025438a49a7d/68747470733a2f2f666c6f78756d2e636f6d2f657874656e73696f6e2f68756f78696e2f6175746f2d696d6167652d64696d656e73696f6e732f62616467652f726576696577)](https://floxum.com/extension/huoxin/auto-image-dimensions) [![Review Score](https://camo.githubusercontent.com/8d12f7e53ccca12ddf396ff80adfc08cbc8cfa69bebf290d48346b2ff4c84fe8/68747470733a2f2f666c6f78756d2e636f6d2f657874656e73696f6e2f68756f78696e2f6175746f2d696d6167652d64696d656e73696f6e732f62616467652f7265766965772d73636f7265)](https://floxum.com/extension/huoxin/auto-image-dimensions)

A [Flarum](https://flarum.org) extension that automatically fetches and applies `width` and `height` dimensions to all `` tags in your forum posts.

By hardcoding the dimensions into the parsed XML of the posts, this extension eliminates Cumulative Layout Shift (CLS), dramatically improving your forum's page performance scores and scrolling experience.

Features
--------

[](#features)

- **Smart Processing**: Uses highly optimized HTTP streams (via `FastImageSize`) to only download the header bytes of remote images, drastically reducing memory and bandwidth overhead.
- **Dynamic Operating Modes**: Choose how the extension extracts dimensions based on your server resources:
    - `Client Mode (Default)`: Forum visitors automatically detect image dimensions in their browser and silently report them back to the server. Best for heavily cached or low-resource servers.
    - `Backend Mode`: The server uses a background Queue Worker to fetch dimensions every time a post is created or edited.
    - `Hybrid Mode`: Combines both approaches for maximum coverage.
- **Data Integrity**: Implements robust Optimistic Locking to ensure background workers never overwrite concurrent user edits.
- **Network Proxy Support**: Configurable proxy settings (e.g. `tcp://10.0.0.5:3128`) for servers behind corporate firewalls.
- **Scheduled Backfills**: Automatically retry failed image fetching on a daily, weekly, or monthly cron schedule.

Installation
------------

[](#installation)

Install with composer:

```
composer require huoxin/auto-image-dimensions:"*"

```

> **Installation Note for Backend Mode:**If you plan to use **Backend** or **Hybrid** mode on an existing forum, the extension will NOT automatically fetch dimensions for your old posts during installation (to prevent server timeout crashes). After enabling the extension, please go to the extension's settings page and click the **"Trigger All"** button, or safely queue your old posts via the terminal by running: `php flarum auto-image-dimensions:backfill`. (If you exclusively use Client mode, no action is required).

CLI Commands
------------

[](#cli-commands)

If you have thousands of existing posts, you can manually trigger a backfill from the command line:

```
# Fetch dimensions for ALL images that don't have them
php flarum auto-image-dimensions:backfill

# ONLY retry images that previously failed (e.g. due to 404s or timeouts)
php flarum auto-image-dimensions:backfill --retry-failed

# Dry-run to see exactly which posts would be queued, without actually queueing them
php flarum auto-image-dimensions:backfill --dry-run --verbose

# Clear all dimensions, optionally see what posts are affected without modifying them
php flarum auto-image-dimensions:clear-all --dry-run --verbose

```

Updating
--------

[](#updating)

```
composer update huoxin/auto-image-dimensions:"*"
php flarum migrate
php flarum cache:clear

```

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/huoxin/auto-image-dimensions)
- [GitHub](https://github.com/huoxin233/flarum-ext-auto-image-dimensions)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

10

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23447157?v=4)[huoxin](/maintainers/huoxin233)[@huoxin233](https://github.com/huoxin233)

---

Top Contributors

[![huoxin233](https://avatars.githubusercontent.com/u/23447157?v=4)](https://github.com/huoxin233 "huoxin233 (89 commits)")[![flarum-bot](https://avatars.githubusercontent.com/u/39334649?v=4)](https://github.com/flarum-bot "flarum-bot (11 commits)")

---

Tags

flarum

### Embed Badge

![Health badge](/badges/huoxin-auto-image-dimensions/health.svg)

```
[![Health](https://phpackages.com/badges/huoxin-auto-image-dimensions/health.svg)](https://phpackages.com/packages/huoxin-auto-image-dimensions)
```

###  Alternatives

[flarum-lang/russian

Russian language pack for Flarum.

13129.1k](/packages/flarum-lang-russian)[fof/byobu

Well integrated, advanced private discussions.

59126.7k16](/packages/fof-byobu)[flarum-lang/french

French language pack to localize the Flarum forum software plus its official and third-party extensions.

1941.0k](/packages/flarum-lang-french)[fof/polls

 A Flarum extension that adds polls to your discussions

26137.4k9](/packages/fof-polls)[fof/discussion-language

Specify the language a discussion is written in &amp; sort by language

1035.6k7](/packages/fof-discussion-language)[fof/masquerade

User profile builder extension for your Flarum forum.

2026.0k7](/packages/fof-masquerade)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
