{"id":384754,"date":"2026-10-11T19:10:47","date_gmt":"2026-10-11T19:10:47","guid":{"rendered":"https:\/\/uk.wordpress.org\/plugins\/kodlo-media-replace\/"},"modified":"2026-10-11T19:10:23","modified_gmt":"2026-10-11T19:10:23","slug":"kodlo-media-replace","status":"publish","type":"plugin","link":"https:\/\/tt.wordpress.org\/plugins\/kodlo-media-replace\/","author":23517482,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.0","stable_tag":"1.0.0","tested":"7.1.3","requires":"6.0","requires_php":"7.4","requires_plugins":null,"header_name":"Kodlo Media Replace","header_author":"Kodlo.dev","header_description":"Replace a media file in place: the same ID, file name and URL. Rebuilds image sizes, keeps old size URLs working and clears browser, page and CDN caches.","assets_banners_color":"62609d","last_updated":"2026-10-11 19:10:23","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"https:\/\/kodlo.dev","rating":0,"author_block_rating":0,"active_installs":0,"downloads":25,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"kodlo","date":"2026-10-11 19:10:23","revision":3740003}},"upgrade_notice":{"1.0.0":"<p>First release.<\/p>"},"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3740125,"resolution":"128x128","location":"assets","locale":"","width":128,"height":128},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3740125,"resolution":"256x256","location":"assets","locale":"","width":256,"height":256}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3740125,"resolution":"1544x500","location":"assets","locale":"","width":1544,"height":500},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3740125,"resolution":"772x250","location":"assets","locale":"","width":772,"height":250}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":3740016,"resolution":"1","location":"assets","locale":"","width":1280,"height":860},"screenshot-2.png":{"filename":"screenshot-2.png","revision":3740016,"resolution":"2","location":"assets","locale":"","width":1280,"height":860},"screenshot-3.png":{"filename":"screenshot-3.png","revision":3740016,"resolution":"3","location":"assets","locale":"","width":1280,"height":860},"screenshot-4.png":{"filename":"screenshot-4.png","revision":3740016,"resolution":"4","location":"assets","locale":"","width":1280,"height":860}},"screenshots":{"1":"The \"Replace file\" box on the edit screen of a media file.","2":"After the replacement: same URL, new image. Old thumbnail URLs keep working even when the proportions change.","3":"The \"Replace file\" link in the Media Library list view.","4":"The \"Replace file\" button in the media details window (grid view)."}},"plugin_section":[],"plugin_tags":[146,163,84,233,166592],"plugin_category":[50,52],"plugin_contributors":[267795],"plugin_business_model":[],"class_list":["post-384754","plugin","type-plugin","status-publish","hentry","plugin_tags-cache","plugin_tags-images","plugin_tags-media","plugin_tags-media-library","plugin_tags-replace-media","plugin_category-media","plugin_category-performance","plugin_contributors-kodlo","plugin_committers-kodlo"],"banners":{"banner":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/banner-772x250.png?rev=3740125","banner_2x":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/banner-1544x500.png?rev=3740125","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/icon-128x128.png?rev=3740125","icon_2x":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/icon-256x256.png?rev=3740125","generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/screenshot-1.png?rev=3740016","caption":"The \"Replace file\" box on the edit screen of a media file."},{"src":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/screenshot-2.png?rev=3740016","caption":"After the replacement: same URL, new image. Old thumbnail URLs keep working even when the proportions change."},{"src":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/screenshot-3.png?rev=3740016","caption":"The \"Replace file\" link in the Media Library list view."},{"src":"https:\/\/ps.w.org\/kodlo-media-replace\/assets\/screenshot-4.png?rev=3740016","caption":"The \"Replace file\" button in the media details window (grid view)."}],"raw_content":"<!--section=description-->\n<p>Need to swap a product photo, an updated PDF price list or a corrected logo without breaking a single link? Kodlo Media Replace overwrites the file of an existing attachment and keeps everything else exactly as it was:<\/p>\n\n<ul>\n<li>the attachment ID,<\/li>\n<li>the file name,<\/li>\n<li>the URL, including every thumbnail URL.<\/li>\n<\/ul>\n\n<p>Pages, products, galleries and page builders that use the file show the new version right away. There is nothing to search and replace.<\/p>\n\n<h4>How it works<\/h4>\n\n<p>Open a file in the Media Library, click <strong>Replace file<\/strong>, choose the new file and confirm. That's it.<\/p>\n\n<h4>What happens behind the scenes<\/h4>\n\n<ul>\n<li><strong>All image sizes are rebuilt<\/strong> with the same function WordPress runs for a new upload.<\/li>\n<li><strong>Old thumbnail URLs keep working.<\/strong> When the new image has different proportions, thumbnail file names would normally change. The plugin recreates the old ones from the new image at their old dimensions, so URLs hard-coded in posts or page builders never return a 404 error.<\/li>\n<li><strong>Large and rotated photos keep their URL<\/strong> (the \"-scaled\" and \"-rotated\" files WordPress creates).<\/li>\n<li><strong>WebP and AVIF copies<\/strong> made by optimization plugins (photo.jpg.webp, photo.webp) are regenerated, so rewrite rules don't keep serving the old picture.<\/li>\n<li><strong>Browser and CDN caches:<\/strong> on the front end, every URL of a replaced file gets a version parameter (?kmr=...), so visitors download the new file immediately, even if the old one was cached for a year.<\/li>\n<li><strong>Page caches are cleared<\/strong> automatically when one of these is active: WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache, WP Fastest Cache, SiteGround Optimizer, WP-Optimize, Breeze, Hummingbird, Cache Enabler, Nginx Helper, WP Engine, Kinsta, Pantheon.<\/li>\n<li><strong>Cloudflare (optional):<\/strong> the replaced file URLs can be purged from the Cloudflare edge. See the FAQ.<\/li>\n<\/ul>\n\n<h4>Simple by design<\/h4>\n\n<p>No settings page, no ads, no tracking. Works with images, PDF files, video, audio and documents.<\/p>\n\n<p>The new file must have the same type as the old one (JPG for JPG, PDF for PDF), otherwise the URL would have to change.<\/p>\n\n<h3>External services<\/h3>\n\n<p>This plugin can connect to the Cloudflare API to remove replaced files from the Cloudflare cache. It is off by default and only works after you add a Cloudflare zone ID and API token to wp-config.php (see the FAQ).<\/p>\n\n<p>When it is enabled, each time you replace a file the plugin sends a request to api.cloudflare.com with your zone ID, your API token and the URLs of the replaced file and its thumbnails (or a \"purge everything\" request if you enabled that option). No other data is sent.<\/p>\n\n<p>This service is provided by Cloudflare, Inc.: <a href=\"https:\/\/www.cloudflare.com\/terms\/\">Terms of Service<\/a>, <a href=\"https:\/\/www.cloudflare.com\/privacypolicy\/\">Privacy Policy<\/a>.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Install the plugin from Plugins &gt; Add New, or upload the ZIP file.<\/li>\n<li>Activate it.<\/li>\n<li>Go to Media &gt; Library, open a file and use the \"Replace file\" box.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id=\"where%20is%20the%20replace%20button%3F\"><h3>Where is the Replace button?<\/h3><\/dt>\n<dd><p>In the Media Library list view, hover over a file and click \"Replace file\". In the grid view, open a file and click \"Replace file\". Both lead to the edit screen of the file, where the \"Replace file\" box is in the right column.<\/p><\/dd>\n<dt id=\"will%20the%20url%20or%20id%20change%3F\"><h3>Will the URL or ID change?<\/h3><\/dt>\n<dd><p>No. The file is overwritten in place. The ID, file name, URL, title, alt text, caption and description stay as they are.<\/p><\/dd>\n<dt id=\"can%20i%20replace%20a%20jpg%20with%20a%20png%3F\"><h3>Can I replace a JPG with a PNG?<\/h3><\/dt>\n<dd><p>No. Changing the type would change the file extension and therefore the URL, which is exactly what this plugin avoids. Convert the new file to the same type first.<\/p><\/dd>\n<dt id=\"i%20still%20see%20the%20old%20image.%20what%20should%20i%20check%3F\"><h3>I still see the old image. What should I check?<\/h3><\/dt>\n<dd><p>Reload the page once without the browser cache (Ctrl+F5 or Cmd+Shift+R). Pages rendered by WordPress get the new version parameter automatically. Files opened by a direct link (for example a PDF link sent by email), or images referenced in external CSS files, can still be served from a CDN until its cache expires. For Cloudflare, set up the automatic purge described below.<\/p><\/dd>\n<dt id=\"how%20do%20i%20enable%20the%20cloudflare%20purge%3F\"><h3>How do I enable the Cloudflare purge?<\/h3><\/dt>\n<dd><p>Create an API token in Cloudflare (My Profile &gt; API Tokens &gt; Create Custom Token) with the permission Zone &gt; Cache Purge &gt; Purge for your domain. Then add this to wp-config.php:<\/p>\n\n<pre><code>define( 'KODLO_MR_CF_ZONE_ID', 'your-zone-id' );\ndefine( 'KODLO_MR_CF_API_TOKEN', 'your-api-token' );\n<\/code><\/pre>\n\n<p>If Cloudflare also caches your HTML pages (APO or a \"Cache Everything\" rule), add:<\/p>\n\n<pre><code>define( 'KODLO_MR_CF_PURGE_EVERYTHING', true );\n<\/code><\/pre><\/dd>\n<dt id=\"does%20it%20work%20with%20offloaded%20media%20%28amazon%20s3%20and%20similar%29%3F\"><h3>Does it work with offloaded media (Amazon S3 and similar)?<\/h3><\/dt>\n<dd><p>No. The plugin replaces files in the local uploads folder. Media offloaded to external storage is not supported.<\/p><\/dd>\n<dt id=\"does%20it%20work%20on%20multisite%3F\"><h3>Does it work on multisite?<\/h3><\/dt>\n<dd><p>Yes, on each site of the network.<\/p><\/dd>\n<dt id=\"can%20i%20use%20it%20from%20code%20or%20wp-cli%3F\"><h3>Can I use it from code or WP-CLI?<\/h3><\/dt>\n<dd><p>Yes:<\/p>\n\n<pre><code>Kodlo_Media_Replace::replace( $attachment_id, '\/path\/to\/new-file.jpg' );\n<\/code><\/pre>\n\n<p>The new file is moved into place. The function returns an array on success or a WP_Error object.<\/p><\/dd>\n<dt id=\"which%20hooks%20are%20available%3F\"><h3>Which hooks are available?<\/h3><\/dt>\n<dd><ul>\n<li><code>kodlo_mr_replaced<\/code> (action): fires after a replacement with the attachment ID and the list of file URLs. Use it to purge other caches.<\/li>\n<li><code>kodlo_mr_purge_page_cache<\/code> (filter): return false to skip clearing page caches.<\/li>\n<li><code>kodlo_mr_rewrite_html<\/code> (filter): return false to stop adding version parameters to the front-end HTML.<\/li>\n<\/ul><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>First release.<\/li>\n<\/ul>","raw_excerpt":"Upload a new version of any media file and keep the same ID, file name and link. Thumbnails are rebuilt and caches are cleared.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/384754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=384754"}],"author":[{"embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/kodlo"}],"wp:attachment":[{"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=384754"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=384754"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=384754"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=384754"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=384754"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/tt.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=384754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}