Version summary
Version : 2.11.0
Module added : Media Replacement
Objective: replace any media file with a new version while preserving media ID, file name and publication date - your existing URLs, integrations and links continue to work.
Why this module is important
Updating a PDF, logo, product image or font without breaking the pages that reference it is a real headache in WordPress. The Media Replacement solves this problem: you upload the new version, we replace the in the same locationthen we regenerating pruning and update metadata. Result: no 404s, no links to correct, no content to republish.
Concrete changes
- In-place replacement copy the new file over the old path (
get_attached_file()). - Keeping references : even ID, slug/identical new name, date and permalinks.
- Strict control of file type the mimetype must correspond (image ↔ image, PDF ↔ PDF, etc.) to avoid inconsistencies.
- Automatic regeneration :
wp_generate_attachment_metadata()+wp_update_attachment_metadata()to rebuild all subsizes (thumbnails, medium, large, etc.). - Reliable cleaning : delete old variants via
wp_delete_attachment_files()and forced file deletion if necessary (including images) -scaled).
User path (in 3 clicks)
- Media library → hover over an item and click Replace media (line action)
(also present in the sidebar of the attachment page and in the media modal) - Drag and drop or select the replacement file.
- The module displays Type, Size and - for images - Dimensions of the old and new files.
- UI safeguards check max size the site and identical mimetype.
- Click Replace. Replacement is instantaneous and your pages remain intact.
Technical details (for the curious)
- Hooks & UI
media_row_actionsadd action Replace media in the list.attachment_fields_to_edit&attachment_submitbox_misc_actionsbutton in the media + modal file.- A submenu hidden under
upload.phpmanages the dedicated UI (before/after preview).
- Security
- Nonce specific to each action.
wp_check_filetype_and_ext()+ blocking if type differs (except role withunfiltered_upload).- Input validation (
sanitize_text_field,is_uploaded_fileupload error handling).
- Replacement & cleaning
- Delete existing files (including sizes and backups) then copy from the new file to the same path.
- Case management "-scaled"and multilingual plug-in protection (e.g. locked files) with a hard suppression in fallback.
- Performance & WPMTK philosophy
- Like all WPMTK : loaded only if activated.
Typical use cases
- PDF update a brochure without changing the URL shared with customers.
- Logo/Charte Refresh a globally used logo (header, footers, builders) without editing the pages.
- E-commerce images Adjust a product photo referenced in hundreds of files.
- Fonts/ICONS replace a static file referenced by theme or builder.
Limits & best practices
- Strict mimetype you can't replace a JPEG by a PNG (or a PDF by a DOCX). Keep the same type.
- Maximum size respect for upload limit of the site (verified in UI).
- Cover if a CDN is in place, purge/wait for propagation to see the new version everywhere.
- Image dimensions If you change the dimensions radically, the appearance may vary where the image is integrated. Check your models.
Quick guide (step-by-step)
- Media → select media → Replace media.
- Upload a file of the same type.
- Check preview, size and (if image) dimensions.
- Confirm: Replace. Visit miniatures are regenerated automatically.
Safety notes & compatibility
- Systematic nonces and server validation on all actions.
- Compatible with Media Library (list, modal, card) and native admin.
- Designed to cohabit with multilingual plugins and custom sizes.
Conclusion
Version 2.11.0 brings major UX update and maintenance end broken URLs when replacing files. Activate the Media Replacement and update your media securely, without friction and without technical debt.