dshovchko / flarum-image-dimensions
Automatically adds width and height attributes to images in Flarum posts for better performance and SEO.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:flarum-extension
pkg:composer/dshovchko/flarum-image-dimensions
Requires
- flarum/core: ^1.0.0
This package is auto-updated.
Last update: 2025-11-06 19:36:44 UTC
README
A Flarum extension that automatically adds width and height attributes to images in posts, improving page load performance and preventing layout shifts.
Features
- 🚀 Automatically detects and adds image dimensions
- ⚡ Adds
loading="lazy"attribute for better performance - 🖼️ AVIF image format support (v1.1.0+)
- 🔍 Console command to check and fix existing posts
- 📧 Email reports for batch operations
- ✅ Supports BBCode, Markdown, and auto-linked images
Installation
composer require dshovchko/flarum-image-dimensions
Usage
Automatic Processing
Once enabled, the extension automatically adds dimensions to all new images posted.
Console Command
Check and fix existing posts:
# Check all discussions php flarum images:check # Fix images (add missing dimensions) php flarum images:check --fix # Check specific discussion php flarum images:check --discussion=123 # Check specific post php flarum images:check --post=456 # Strict mode (verify exact dimensions) php flarum images:check --strict # Send report via email php flarum images:check --mailto=admin@example.com
Supported Image Formats
- JPG/JPEG
- PNG
- GIF
- WebP
- SVG/SVGZ
- AVIF (v1.1.0+, dimensions require PHP 8.2+)
Why Image Dimensions Matter
Adding width and height attributes to images:
- Prevents Cumulative Layout Shift (CLS)
- Improves Core Web Vitals scores
- Enhances SEO rankings
- Provides better user experience
Requirements
- Flarum ^1.0
- PHP 8.1+ (PHP 8.2+ recommended for full AVIF support)