Official WordPress URL with download and more information: http://wordpress.org/extend/plugins/enable-media-replace/
This plugin lets users replace media files by adding a method for uploading new content while keeping the old filename. This saves the user from having to first delete an attachment from the library, then uploading a new attachment with the exact same name.


Suveränt plugin. Får det inte att funka i IE 8 men det fungerar utmärkt i FF och GC.
Tack! Men, det var märkligt, där ska inte finnas något script som skulle ställa till problem med IE8, men jag ska försöka hitta en dator med IE8 att testa i.
Great plugin, and it works well for me with all browsers except IE8. Any chance of fixing this?
Thank you Penny,
I would love to fix the problems with IE 8, but I have no opportunity to test it in IE 8 myself. Could you please tell me more about what doesn’t work – are there any error messages, etc?
To everybody: I just submitted version 1.1 to wordpress.org which corrects the bug with IE8. Update the plugin and it should work fine even in that browser.
/M;
Works great, thank you
Great plugin. It would be nice to be able to enable this feature in the Pages/Posts media browser as well. On a site that has 10+ pages of media images, it gets a little tedious trying to find the one you’re looking for.
It’s a great plugin though. It has saved me a lot of time. Thanks
Thanks Matt, that’s actually a very good idea. I’m not sure it is easy to do, but I’ll definately take a look at it soon!
/M;
Hej Måns!
Har du gjort en meny som är som http://www.blondinbella.se
Jag skulle vilja ha en meny som hon har. Kolla speciellt in Arkivmenyn och även hur populärt, senaste och kategorier fungerar.
Har letat på svenska WP efter en sån meny och även en funktions som tar fram det som är populärast i min blogg. Ja, kolla Blondinbellas blogg… Snälla…
// Steffi
Stephanie: Ja, det har jag. Det heter WordPress Page Tree och går fint att ladda ner från WordPress här: http://wordpress.org/extend/plugins/page-tree/
Tack, ska testa den menyn :)
Hej!
Tack för ett smart plugin. Tyvärr får jag det inte att funka i vår wp mu installation. När jag klickar på länken för att ladda upp en ny fil så visas endast en blank sida i popupfönstret.
Är det så att pluggen inte funkar i wp-multiuser?
Hej Torbjörn,
bra fråga – jag har faktiskt inte testat den i WPMU – vilken version av WPMU använder du?
// Drop-in replace and we don’t even care if you uploaded something that is the wrong file-type.
// That’s your own fault, because we warned you!
I LOVE LOVE LOVE the plugin, except this part above. We run a multisite environment where the users are FAR from tech-savvy or careful, and i guarantee someone WILL upload the wrong file type. I’d love for a file type check to exist in here, or be an option from the admin side.
What do you think?
thanks for great plugin!
– Jason
Haha, you got me. That was lazy of me, but I really wanted the first option to be forgiving so that somebody could upload a PNG instead of a JPG and it would just magically work.
But I guess you are right – the possibilities for screwups are endless. Right now I have very limited time for plugin development, but I’ll try to take a look at this soon and come up with something smart. Maybe just a checkbox in the upload form to the effect of “Yes, I know I’m doing something wrong here – let me!”
/M;
Thanks for the quick response!
My brief testing shows that switching between image types DOES seem to work pretty well, but switching other types does not.
How difficult would it be to add something like:
function validate_file_types(old_image, new_image) {
if (same_file_type) {
//yay, you followed the rules
return true;
}
if (is_image_file(old_image) && is_image_file(new_image)) {
//well you didn’t technically follow the rules, but this should work anyway
return true;
}
}
//different file types, at least one of em isn’t an image
//this is for your own good!
return false;
}
That’s along the lines of what I was thinking. I’m just not 100% sure it’s kosher to serve up something else than what is expected. Say the original file was a .jpg and somebody uploads a .png instead. Now WP will suddenly serve a browser a file called “image.jpg” but with mime-type image/png and PNG content.
Although I’m sure this will technically work in everything but (possibly) IE6, it goes against my strong belief in following web standards.
The jury’s still out. I guess it wouldn’t be too bad to also update the file name and all links pointing to it, but then we lose the great “drop-in” replacement function that is so good for permanent file URLs.
Thoughts?
Good point – that doesn’t seem “right.”
I should not be allowed to replace foo.jpg with bar.png, even if it “works.”
Here’s another way to look at it:
Most advanced users will have ftp access to their servers, and will be able to do, pretty easily, what this module does via that route.
I see this module being great for inexperienced users who need some hand-holding. Those types of people should have stricter safeguards in place to protect their content and links.
Because of that, I think I (personally) would go with the side of “only direct replace with file of same type.”
Does that make sense? IS that a reasonable way to look at it?
Possibly. I’ll probably go this route when I update the plugin next.
Hi
i have just installed your plugin and i think it wont work if you are using another plugin called “contact-form-7″…
When i click on “upload new file” for the replacement file i get the following error in a pop up:
Fatal error: Call to undefined function wpcf7_add_tag_generator() in /home/setarch/www/setar.ch/wp-content/plugins/contact-form-7/modules/text.php on line 129
Do you have any idea why this is happening ?
Thanks
Sorry, I have no idea why this is.
I get the following when trying to upload a new image in the media library:
Warning: require_once(E:\domains\r\rainbowdesign.co.uk\user\htdocs\wp-content\plugins\enable-media-replace\popup.phpwp-load.php) [function.require-once]: failed to open stream: No such file or directory in E:\domains\r\rainbowdesign.co.uk\user\htdocs\wp-content\plugins\enable-media-replace\popup.php on line 5
Fatal error: require_once() [function.require]: Failed opening required ‘E:\domains\r\rainbowdesign.co.uk\user\htdocs\wp-content\plugins\enable-media-replace\popup.phpwp-load.php’ (include_path=’.;C:\php5\pear’) in E:\domains\r\rainbowdesign.co.uk\user\htdocs\wp-content\plugins\enable-media-replace\popup.php on line 5
I’m no PHP expert – can you help me out?
Cheers.
This looks like a configuration error on a Windows server to me. Never seen anything like it before.
Basically – the issue from before lies with the URL file access not being configured on the windows server. I don’t have access to this being as my client has a useless fasthosts account.
I recommend that anyone using this plugin be sure that they are using a windows server they can access or a linux/apache set up.
Another Potential Issue (i apologize if this isn’t the current avenue for this)
The problem arises when using the different Photo Sizes wordpress provides.
Consider the following steps:
Upload a photo.
Embed a thumbnail in a post.
Replace the file with the second option.
The post still shows the original file’s thumbnail.
Perhaps this could be corrected by some use of regular expressions when updating the links to the file? I’d love to help, but RegEx is my kryptonite.
Thanks again for the plugin. I hope my finding/poking holes doesn’t suggest I don’t like the plugin. I just have to make sure it’s perfect before we use it on a wider scale! Thanks again! :D
You are right. Those WordPress thumbnails are evil and I never use them myself, mainly because of issues like this. I don’t think there’s much I can do about that unfortunately, but I’ll look into re-generating the thumbnails after uploading a new image file.
/M;
Mans,
I don’t think you have to re-generate the image, you just have to update the tags in posts/pages.
For example, I Replaced “version1.png” with “version2.png”, and when a size was selected, the original post contained this originally:
src=”[site]/wp-content/uploads/2010/01/version1-150×150.png”
All that needs to happen is that the above part of the post needs the “version1″ part become “version2″.
i.e.:
src=”[site]/wp-content/uploads/2010/01/version2-150×150.png”
So no new thumbnails need to be generated, we just need to use RegEx to be a little more general in the replace. I’m guessing something like:
replace: [original_file_name_without_extension][optional dash][any number of optional numbers and 'x']“.”[file_extension]
with
[new_file_name_without_extension][optional dash][any number of optional numbers and 'x']“.”[file_extension]
Like I said, I suck at RegEx, but i think that would cover these specified size cases as well. Any thoughts?
Thanks again!
Blargh – as an addendum to this, WP also adds crap like this:
height=”150″ width=”150 to the img tag, not just the filename. so that’s even more crap to replace.
I’m kinda wishing I had a version that only allowed files from a list like:
.txt
.doc/x
.ppt/x
.xls/x
.pdf
and maybe a few others :/
Yes, and this is why I can’t make too many “smart” changes to posts, since it might not be the best option to change the size of the image in a post, if the poster intended the image to be a certain size.
No, I would indeed have to re-generate the thumbnails. WordPress does not dynamically resize the images, but only generates thumbnails in the set sizes upon first upload. So if I change the picture the thumbnails need to be regenerated.
Hi there. I am from Spain and i find your plugin great. If you need a spanish translation i will be glad to help. Thanks any way for the plugin.
Lucass
Hi Lucas, thanks for the kind words. If you or anybody else wants to translate the plugin, the .mo/.po files you need are included with the plugin. Thanks.
How can I use my own language translation? I see translation files, I tranlsated everything but how do I use these?
The translation files have to be in a compiled .mo format. I recommend PoEdit ( http://www.poedit.net/ ) a free tool to compile translation files for WP and other po/mo projects.
/M;
This seems like a great plugin but it has not been working for me. Every time I click the link to replace media (Upload a new file) it opens a blank browser. Any suggestions?
Not really, but I have heard of similar problems elsewhere. Have you tried it in several different browsers?
Yea, I have tried it in firefox 3.6, ei6, and chrome.
I get a similar error as mentioned above…. stink. This really looked like a winner.
Warning: require_once(D:\Hosting\2674371\html\wp-content\plugins\enable-media-replace\popup.phpwp-load.php) [function.require-once]: failed to open stream: No such file or directory in D:\Hosting\2674371\html\wp-content\plugins\enable-media-replace\popup.php on line 5
Fatal error: require_once() [function.require]: Failed opening required ‘D:\Hosting\2674371\html\wp-content\plugins\enable-media-replace\popup.phpwp-load.php’ (include_path=’.;C:\php5\pear’) in D:\Hosting\2674371\html\wp-content\plugins\enable-media-replace\popup.php on line 5
This should have been fixed in 2.0. Please upgrade and try again.
Hi
Nice plugin. I am trying it out now. How can I make this feature available to a user without an admin role? I tried changing a role to have “upload_files” capability, but that didn’t seem to work. I still get the following message “You do not have sufficient permissions to access this page.” after I click on “Upload a new file”. I am using WP 2.9.2.
That SHOULD work. Which role does the user have that is getting the insufficient permissions error?
Also, please try the latest version first.
In WordPress 3.0 I’m getting two notices related to your plugin:
Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in //wp-includes/functions.php on line 3323
Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in //wp-includes/functions.php on line 3321
Also I noticed these notices show up on the front-end too, is there any reason this plugin loads on the front-end? Can an updated version only load on the backend?
Thanks for a great plugin, let me know if you need any help, I already have a version running with these things fixed.
Here are the edits:
enable-media-replace.php
Line 28:
add_submenu_page(‘upload.php’, __(“Enable Media Replace”, “enable-media-replace”), __(“Replace media”, “enable-media-replace”), ‘upload_files’, __FILE__, ‘emr_options’);
Line 34:
load_plugin_textdomain( ‘enable-media-replace’ );
Sorry missed one, the line numbers in the previous comment were off by one because I added one line at the top of that file:
Line 17:
if( !is_admin() ) return;
One more that I didn’t see until I fixed the others. When on the “Replace Media” admin page I get this now:
Notice: Undefined index: attachment_id in /var/www/vhosts/seedgiveslife.net/httpdocs/wp-content/plugins/enable-media-replace/enable-media-replace.php on line 50
So I made this edit once again to “enable-media-replace.php”
Line 50 (or 49) :
if ( array_key_exists(‘attachment_id’, $_GET) && $_GET["attachment_id"] > 0) {
Thank you Jim! For finding the bugs and squashing them for me. :) I’m about to commit 2.0.2 to WP servers, so you’ll have an updated version soon.
[...] Enable Media Replace – This plugin enables replacing media files by uploading a new file in the “Edit Media” section of the WordPress Media Library. [...]
2.1 seems to be having some problems with WordPress 3.0
Initially it gives this error:
Warning: require_once(E:\inetpub\vs188120\wordpress\wp-content\plugins\enable-media-replace\upload.phpwp-load.php) [function.require-once]: failed to open stream: No such file or directory in E:\inetpub\vs188120\wordpress\wp-content\plugins\enable-media-replace\upload.php on line 6
Fatal error: require_once() [function.require]: Failed opening required ‘E:\inetpub\vs188120\wordpress\wp-content\plugins\enable-media-replace\upload.phpwp-load.php’ (include_path=’.;e:\php\includes’) in E:\inetpub\vs188120\wordpress\wp-content\plugins\enable-media-replace\upload.php on line 6
If I hard code the $wppath like this
$wppath = “http://www.mhrt.qld.gov.au/wordpress/”;
then it gives this error:
Fatal error: Call to undefined function current_user_can() in E:\inetpub\vs188120\wordpress\wp-content\plugins\enable-media-replace\upload.php on line 9
any ideas? was current_user_can() deprecated in 3.0? I tried replacing the code with a similar function using get_role() to see if the administrator was logged in, then checking for capabilities to see if they were allowed to upload_files. But that didn’t work either – get_role() function was undefined.
Something’s not right. Can someone have a look please?
Is it possible to add the “replace media” link to the options that appear when someone clicks “show” from a page or a post.
Within a page or a post clicking ‘add media’ and then either clicking the ‘media library’ or ‘gallery tag’. The options that appear when ‘show’ is clicked.
That way someone updating a page or post can do everything from the page/post without having to go somewhere else in the dashboard.
Hopefully that was clear enough. Thanks!
Håller på att “testa upp” wn WP-sajt. Enable-media-replace raderar ofta mina “media-tags”, som är taggar på uppladdade bilder som man fixar med en annan plug-in som heter Media Tags. Den är viktigare för mej, men din är också värdefull men den får inte radera med möda hopsamlad tagginfo. Var snäll och kolla detta. Kanske något SQL som ibland blir för yvigt för tabellen wp_term_relationships, t.ex.?
Tack – kan du berätta exakt vilket/vilka plugin som skapar de taggar du vill behålla?
Troligen är det inte superlätt att behålla dem, eftersom de troligen läggs i en egen databastabell, helt frikopplat från WP, men jag kan ju kolla.
/M;
There seems to be a typo in the latest version of this plugin.
Line 26 of popup.php
$forumurl = str_replace(“http:”, “https:”, $formurl);
should be
$formurl = str_replace(“http:”, “https:”, $formurl);
This seems to solve some problems we’ve been having.
http://wordpress.org/support/topic/plugin-enable-media-replace-incompatible-with-ssl-dashboard?replies=2
Thanks Bill, I’ll check it out and update as necessary.
excellent, thanks!
This looks like a great plugin, but I just get a blank page when I click “Upload”. I’m on Windows Server 2008 / IIS if that matters… Something extra I need to configure?
I’ve just installed the plugins on a wordpress 3.01 installation and I get the following errors when trying to upload an image.
Warning: require_once(E:\xampplite\htdocs\intranet\wp-content\plugins\enable-media-replace\upload.phpwp-load.php) [function.require-once]: failed to open stream: No such file or directory in E:\xampplite\htdocs\intranet\wp-content\plugins\enable-media-replace\upload.php on line 5
Fatal error: require_once() [function.require]: Failed opening required ‘E:\xampplite\htdocs\intranet\wp-content\plugins\enable-media-replace\upload.phpwp-load.php’ (include_path=’.;\xampplite\php\PEAR’) in E:\xampplite\htdocs\intranet\wp-content\plugins\enable-media-replace\upload.php on line 5