Image Dimensions

Image Dimensions dshovchko/flarum-image-dimensions

Automatically adds width and height attributes to images in Flarum posts for better performance and SEO.

Flarum Image Dimensions

MIT license Latest Stable Version Total Downloads

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 [email protected]

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)

Links

License

MIT

Versions

  • Version v1.0.0.

    Likely works with Flarum v1.8.11.

  • Extension created.