PHPackages                             dshovchko/flarum-image-migrate - 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. [Database &amp; ORM](/categories/database)
4. /
5. dshovchko/flarum-image-migrate

ActiveFlarum-extension[Database &amp; ORM](/categories/database)

dshovchko/flarum-image-migrate
==============================

Check and migrate external images in posts

v1.2.0(6mo ago)2670↓73.2%MITPHP

Since Nov 23Pushed 6mo agoCompare

[ Source](https://github.com/dshovchko/flarum-image-migrate)[ Packagist](https://packagist.org/packages/dshovchko/flarum-image-migrate)[ RSS](/packages/dshovchko-flarum-image-migrate/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

Flarum Image Migrate
====================

[](#flarum-image-migrate)

[![MIT license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/dshovchko/flarum-image-migrate/blob/main/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/0a7875f1ace72b0da39afd6d2d07e9074bf32a84ea5dfc51fdcc753aa7b8db32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6473686f7663686b6f2f666c6172756d2d696d6167652d6d6967726174652e737667)](https://packagist.org/packages/dshovchko/flarum-image-migrate)[![Total Downloads](https://camo.githubusercontent.com/0d105e6b920131a64ebf05e6f6618c4785e6dcc343896c2ae46970d732d258b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6473686f7663686b6f2f666c6172756d2d696d6167652d6d6967726174652e737667)](https://packagist.org/packages/dshovchko/flarum-image-migrate)

A Flarum extension that detects external images in posts and helps migrate them to your own storage.

Features
--------

[](#features)

- 🔍 Detects external images from non-whitelisted domains
- 🛠 Migration mode (`--fix`) that downloads external files, pushes them to your configured backend, and rewrites post content automatically
- 📧 Email reports with detailed statistics and optional on-demand emails
- ⏰ Scheduled automatic checks (daily/weekly/monthly)
- 🎯 Flexible checking: all posts, specific discussion, or single post
- 🔑 Admin-configurable backend credentials with built-in health-check
- 📊 Grouped reporting by discussions and posts, plus a persistent audit log for migrated URLs
- ⚙️ Configurable allowed domains

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

[](#installation)

```
composer require dshovchko/flarum-image-migrate
```

Usage
-----

[](#usage)

### Configuration

[](#configuration)

Configure the extension via the admin panel:

1. Go to **Admin → Extensions → Image Migrate**
2. Set **Allowed Origins** (comma-separated domains, e.g., `example.com, cdn.example.com`)
3. Provide the backend connection details: **Backend Base URL**, **Backend Environment** (production/sandbox/etc.), and **Backend API Key**
4. Enable **Scheduled Checks** (optional)
5. Set **Check Frequency** (daily/weekly/monthly)
6. Add **Email Recipients** (comma-separated)

Saving the settings will ping the backend health endpoint; the form cannot be saved while the backend is unreachable. After upgrading to v1.1.0, run `php flarum migrate` once to create the migration log table.

> ⚠️ Scheduled checks require Flarum scheduler to be configured. Add to your crontab:
>
> ```
> * * * * * cd /path/to/flarum && php flarum schedule:run >> /dev/null 2>&1
> ```

### Manual Console Command

[](#manual-console-command)

Check for external images using the `image-migrate:check` console command:

```
# Check a single discussion
php flarum image-migrate:check --discussion=123

# Check a specific post
php flarum image-migrate:check --post=456

# Scan all discussions
php flarum image-migrate:check --all

# Run the scan and migrate matching images immediately
php flarum image-migrate:check --all --fix

# Run the scan and migrate matching images immediately with scale
php flarum image-migrate:check --all --fix --scale=1.5

# Email the report
php flarum image-migrate:check --all --mailto=admin@example.com

# Combine options
php flarum image-migrate:check --all --mailto=admin@example.com,moderator@example.com
```

> ℹ️ The command requires one of `--discussion=`, `--post=`, or `--all`. 🔐 When using `--fix`, the backend settings must be valid and reachable.

### Migration Mode (`--fix`)

[](#migration-mode---fix)

When `--fix` is present, the command will:

1. Run the same detection logic as the regular scan
2. Download each external image to a temporary file
3. Upload it to the configured backend using the selected environment
4. Replace the original `src` attribute in the post with the new URL
5. Store an entry in `dshovchko_image_migrate` for auditing (discussion/post IDs, author, old/new URLs)

The command aborts on the first failed upload so that no discussion is partially migrated. Consider running without `--fix` first to review the report, then re-run with `--fix` for the same filters.

> 🔁 If the SnapGrab backend reports a duplicate upload (HTTP 208), the migration stops immediately and the CLI prints both the original external URL and the already-hosted optimized asset so you can reconcile the post manually. No changes are written to the post in that scenario.

### Email Reports

[](#email-reports)

Reports include:

- Total number of external images found
- Number of discussions with issues
- Detailed breakdown by discussion and post
- Direct links to affected discussions and posts
- List of external image URLs

Example report format:

```
External Images Report

Total external images: 56
⚠️ Discussions with issues: 8
==================================================

⚠️ Discussion 8
https://example.com/d/8
 external images in posts (10)
 posts: 14 15 16 17 18 19
  Post #14: 3 image(s)
    https://example.com/d/8/1
    - https://external-cdn.com/image1.jpg
    - https://external-cdn.com/image2.jpg

```

How It Works
------------

[](#how-it-works)

1. The extension scans post content for `` tags
2. Extracts image URLs from the `src` attribute
3. Compares image domains against your allowed origins list
4. Reports any images hosted on external domains
5. Groups results by discussion and post for easy review

Allowed Origins
---------------

[](#allowed-origins)

Domains in the allowed origins list are considered "internal" and won't be flagged:

- Exact domain match: `example.com` matches `example.com`
- Subdomain match: `example.com` matches `cdn.example.com`, `images.example.com`
- Case-insensitive matching
- Automatic `www.` prefix handling

Requirements
------------

[](#requirements)

- Flarum ^1.0
- PHP 7.4+

Release Checklist
-----------------

[](#release-checklist)

When tagging a new version:

1. Run `cd js && npm ci && npm run build` to regenerate `js/dist/admin.js`.
2. Commit the updated `js/dist` assets together with any code changes (do **not** rely on production servers having Node.js available).
3. Update `CHANGELOG.md` with the new version and summary.
4. Tag the release (`git tag -a vX.Y.Z -m "vX.Y.Z"`) and push the tag to origin.

This ensures Packagist builds include the already-tested TypeScript admin bundle.

Development
-----------

[](#development)

The admin UI is authored in TypeScript and lives in `js/src/admin` (entry point `js/admin.ts`). To work on it locally:

1. `cd js`
2. `npm ci`
3. `npm run dev` for a watch build or `npm run build` for a production bundle

Webpack reads `tsconfig.json`, so updating the TypeScript sources automatically recompiles the `js/dist/admin.js` asset that ships with the extension.

Future Features
---------------

[](#future-features)

- Automatic retries/backoff for flaky external hosts
- Extended reporting in the admin panel
- Additional image transformation presets

Links
-----

[](#links)

- [GitHub Repository](https://github.com/dshovchko/flarum-image-migrate)
- [Packagist](https://packagist.org/packages/dshovchko/flarum-image-migrate)
- [Flarum Community](https://discuss.flarum.org)

License
-------

[](#license)

[MIT](https://github.com/dshovchko/flarum-image-migrate/blob/main/LICENSE)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

7

Last Release

209d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1fa673650ec9d6d6af0b6da7a93aa4426ce230de1fc3af7791bbb20f35d8717d?d=identicon)[dshovchko](/maintainers/dshovchko)

---

Top Contributors

[![dshovchko](https://avatars.githubusercontent.com/u/564184?v=4)](https://github.com/dshovchko "dshovchko (40 commits)")

---

Tags

automationcontent-migrationexternal-imagesflarumflarum-extensionimage-downloaderimage-migrationphpmigrationimagesflarum

### Embed Badge

![Health badge](/badges/dshovchko-flarum-image-migrate/health.svg)

```
[![Health](https://phpackages.com/badges/dshovchko-flarum-image-migrate/health.svg)](https://phpackages.com/packages/dshovchko-flarum-image-migrate)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[flarum-lang/russian

Russian language pack for Flarum.

12128.3k](/packages/flarum-lang-russian)[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

191192.5k18](/packages/fof-upload)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)[flarum-lang/french

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

1938.7k](/packages/flarum-lang-french)

PHPackages © 2026

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