WP Manifestindependent plugin directory
manifest / performance / replace-thumbnail-url

Replace Thumbnail URL

Wordpress plugin to replaces the site URL with a custom one in attachment image URLs

★ 0stars
1.2latest · 3mo ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/abidarm/replace-thumbnail-url/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

WordPress plugin that rewrites attachment image URLs to use a custom domain (for example a CDN or public site URL) instead of the current site URL.

Works as a standard plugin or as a must-use (mu) plugin.

Requirements

Requirement Version
WordPress 5.0 or higher
PHP 7.4 or higher

Features

  • Rewrites domains in attachment URLs (wp_get_attachment_url)
  • Rewrites sized image src values (wp_get_attachment_image_src / related helpers)
  • Rewrites srcset URLs (wp_calculate_image_srcset)
  • Settings field under Settings → Media to set the custom media domain
  • Defaults to the current site URL (no rewrite) until you change it

Installation

Standard plugin

  1. Copy the replace-thumbnail-url folder into wp-content/plugins/.
  2. In Plugins, activate Replace Thumbnail URL.
  3. Go to Settings → Media and set Custom media domain if needed.

Must-use (mu) plugin

Must-use plugins load automatically and cannot be deactivated from the admin UI.

WordPress only autoloads PHP files directly in wp-content/mu-plugins/ (not in subfolders).

Option A — single file

  1. Copy replace-thumbnail-url.php into wp-content/mu-plugins/.
  2. Done. The plugin is active on every request.

Option B — keep the folder (recommended if you want the README nearby)

  1. Copy the whole replace-thumbnail-url folder into wp-content/mu-plugins/replace-thumbnail-url/.
  2. Add a loader at wp-content/mu-plugins/replace-thumbnail-url-loader.php:
<?php
/**
 * Plugin Name: Replace Thumbnail URL (MU loader)
 * Description: Loads Replace Thumbnail URL as a must-use plugin.
 */
require_once __DIR__ . '/replace-thumbnail-url/replace-thumbnail-url.php';
  1. Done. Settings remain available under Settings → Media.

Configuration

  1. Open Settings → Media.
  2. Find Attachment URL domain.
  3. Set Custom media domain to the public/CDN base URL (no trailing slash required).
  4. Save changes.

Leave the field as the current site URL (or empty, which falls back to the site URL) to disable rewriting.

How it works

When a custom domain differs from site_url(), the plugin replaces the site URL prefix in:

  • Attachment file URLs
  • Attachment image src URLs
  • Responsive image srcset URLs

Stored attachment paths in the database are not changed; only URLs returned by WordPress filters are rewritten on output.

Author

Mohamed Abidar

License

Use and modify as needed for your projects.

Releases

1 release.

Tag
Published
1.2 latest
Jul 18, 2026 3mo ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.