https://github.com/bjornfix/devenia-replace-media
WordPress plugin to replace images and files while keeping the same URL. Works with Elementor and Gutenberg.
https://github.com/bjornfix/devenia-replace-media
elementor media-library wordpress wordpress-plugin
Last synced: 5 months ago
JSON representation
WordPress plugin to replace images and files while keeping the same URL. Works with Elementor and Gutenberg.
- Host: GitHub
- URL: https://github.com/bjornfix/devenia-replace-media
- Owner: bjornfix
- Created: 2025-12-09T19:39:28.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-17T00:46:44.000Z (6 months ago)
- Last Synced: 2026-01-13T21:19:44.667Z (6 months ago)
- Topics: elementor, media-library, wordpress, wordpress-plugin
- Language: PHP
- Homepage: https://devenia.com/plugins/replace-media/
- Size: 24.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Devenia Replace Media
**Replace images and files while keeping the same URL.** Works with Elementor and Gutenberg.
[](https://wordpress.org)
[](https://php.net)
[](https://www.gnu.org/licenses/gpl-2.0)
## The Problem
You uploaded an image. It's used in 47 places across your site. Now you need to replace it with a better version.
WordPress gives you two bad options:
1. Delete the old image, upload new one, manually update all 47 places
2. Upload with same filename and pray the cache clears
## The Solution
This plugin adds a "Replace File" button to every image in your media library. Click it, upload the new file, done. Same URL, new file, automatic cache busting.
## Features
- Replace any file in media library (images, PDFs, etc.)
- Keeps the same URL - no broken links
- Works in Media Library, Elementor gallery editor, anywhere WordPress media is used
- Preserves captions, alt text, and all metadata
- Automatic cache busting so visitors see the new file immediately
- Regenerates all thumbnail sizes
## Installation
1. Download from [Releases](https://github.com/bjornfix/devenia-replace-media/releases)
2. Upload via WordPress Admin → Plugins → Add New → Upload Plugin
3. Activate the plugin
That's it. No settings to configure.
## How to Use
1. Go to Media Library
2. Click on any image
3. Click "Replace File" button
4. Upload your new file
5. Done - all instances across your site now show the new image
The button also appears in Elementor's gallery editor when editing an image.
## How It Works
When you replace a file:
1. The new file overwrites the old one on disk
2. All thumbnail sizes are regenerated
3. A version parameter is added to URLs (`?v=timestamp`)
4. Browser caches are bypassed, visitors see the new file immediately
## Requirements
- WordPress 5.0+
- PHP 7.4+
## Changelog
### 1.7.5
- Fixed: Replace File button injection in Media Library grid/details view on newer WordPress admin markup
- Improved: More robust attachment ID detection across WP media frames and DOM
- Fixed: Media Library grid view details modal now detects attachment ID via `?item=`
- Improved: Cache busting now also applies to responsive image `srcset` and works across repeated replacements
- Improved: After replacement, Media Library refresh behavior is more reliable
- Improved: Safer file replacement flow (staged write + rollback) and stricter permissions check
### 1.7.4
- Added Replace File button on Edit Media screen
### 1.7.3
- Fixed: Use wp_add_inline_script() instead of raw script tags
- Fixed: Added nonce verification for GET requests
- Fixed: Improved file upload validation
- Added: User capability checks
### 1.7.2
- Changed slug to devenia-replace-media (WordPress.org requirement)
### 1.7.1
- Fixed text domain to match plugin slug
### 1.7
- Fixed nonce verification warnings
- Improved input validation for WordPress.org Plugin Check compliance
### 1.6
- Uses WordPress Filesystem API for all file operations
- Improved security and WordPress.org compatibility
### 1.5
- Added automatic cache busting - URLs include version parameter after replacement
- Browsers automatically fetch new files without manual cache clearing
### 1.4
- Added support for Elementor gallery editor
### 1.3
- Changed script loading method for better compatibility
### 1.2
- Improved attachment ID detection in media modals
### 1.1
- Added JavaScript injection for media modal support
### 1.0
- Initial release
- Replace files from Media Library list view
- Preserve metadata and regenerate thumbnails
## License
GPL-2.0+
## Author
[Devenia](https://devenia.com) - We've been doing SEO and web development since 1993.
## Links
- [Plugin Page](https://devenia.com/plugins/replace-media/)