Enable Media Replace

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.


Kommentarer

30 svar to “Enable Media Replace”

Lämna ett svar
  1. Suveränt plugin. Får det inte att funka i IE 8 men det fungerar utmärkt i FF och GC.

  2. Mans says:

    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.

  3. Penny says:

    Great plugin, and it works well for me with all browsers except IE8. Any chance of fixing this?

  4. Mans says:

    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?

  5. Mans says:

    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;

  6. baron says:

    Works great, thank you

  7. Matt says:

    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

  8. Mans says:

    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;

  9. Stephanie says:

    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

  10. Mans says:

    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/

  11. Torbjörn says:

    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?

    • Måns Jonasson says:

      Hej Torbjörn,

      bra fråga – jag har faktiskt inte testat den i WPMU – vilken version av WPMU använder du?

  12. MadtownLems says:

    // 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

    • Måns Jonasson says:

      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;

      • MadtownLems says:

        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;
        }

        • Måns Jonasson says:

          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?

          • MadtownLems says:

            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?

  13. dömsel says:

    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

  14. Jay says:

    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.

    • Måns Jonasson says:

      This looks like a configuration error on a Windows server to me. Never seen anything like it before.

  15. MadtownLems says:

    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

    • Måns Jonasson says:

      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;

      • MadtownLems says:

        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!

        • MadtownLems says:

          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 :/

          • Måns Jonasson says:

            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.

        • Måns Jonasson says:

          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.

  16. Lucas says:

    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

    • Måns Jonasson says:

      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.

Creeper