Overwrite Uploads
[resolved] Will this plugin be updated? (6 posts)

  1. Hello,

    I've just run across your plugin via a wpquetions.com issue. The developer suggested your plugin as a fix for a Woocommerce issue of duplicating images. I too am having that same problem although would love to know if you are still maintaining this plugin before I start relying on it.

    Do you have plans for an update? Did you get any feedback from WordPress as far as installing the hook into the core?

    Thank you for your time and expertise. Guys like myself need guys like you :)



  2. khungate
    Posted 2 years ago #

    +1 on this

    I've installed on WP 3.5, followed instructions and it doesn't work unfortunately. I too am trying to fix and issue with Woocommerce. I'll be glad to donate if you're still actively working on this plugin.

  3. Ian Dunn
    Plugin Author

    Posted 2 years ago #

    I am planning on updating it when the WP core team adds the hook. It was slated for the 3.5 release, but got pushed back to 3.6. You can add yourself to the trac ticket to get e-mail updates on it. If it's important to you, leaving a comment on the ticket might help raise the priority of it, too.

    khungate, it works for me in 3.5. Could you start a new thread with a detailed explanation of problem?

  4. toto
    Posted 2 years ago #

    Its great idea for this plugin to work, they have to add the new filters.
    How we can help?

  5. toto
    Posted 2 years ago #

    Replace/Overwrite Media upload without loosing post thumbnails

    Try to check this code:

    // Force Media manager to overwrite files of same name?
    add_filter( 'sanitize_file_name', 'filename_filter_wpse_28439', 10, 1 );
    function filename_filter_wpse_28439( $name ) {
      // Get all attachments with same name
        $args = array(
            'numberposts'   => -1,
            'post_type'     => 'attachment',
            'meta_query' => array(
                        'key' => '_wp_attached_file',
                        'value' => $name,
                        'compare' => 'LIKE'
        $attachments_to_remove = get_posts( $args );
        foreach( $attachments_to_remove as $attach ) {
            // Check all posts with this attacment
            if (have_posts()) :
              while (have_posts()) : the_post();
                    // Set temporal marker
                    update_post_meta( get_the_ID(), '_temp_thumbnail_id', $name );
        // Delete old attachment
         wp_delete_attachment( $attach->ID, true );
        return $name;
        // Continue and upload new attachment with simple name
    // Set new attachment to posts
    add_action("add_attachment", 'attachment_manipulation');
    add_action("edit_attachment", 'attachment_manipulation');
    function attachment_manipulation($post_ID) {
      $file = get_attached_file($post_ID);
      $path = pathinfo($file);
      $filename = $path['filename'].'.'.$path['extension'];
        // Check all posts for temporal marker
          if (have_posts()) :
            while (have_posts()) : the_post();
                // If found marker set postthumb with new attachment
      	        update_post_meta( get_the_ID(), '_thumbnail_id', $post_ID  );
                // Cleanup temporal marker
      	        delete_post_meta( get_the_ID(), '_temp_thumbnail_id', $post_ID  );

    Is it useful, test for bugs, any suggestions?

    More discussions:

    WP 3.3 > Still no option to enable automatic image overwrites?

    Hot to make on Upload New Media to replace files with same name?

    How do I replace images without FTP?

    How Do I Stop Incremental Naming In Media Library?

    Which filters or actions to use after a media upload and delete?

    Change attachment filename

    How to force Media manager to overwrite files of same name?

    Enable Media Replace – Replace Images Instead Of Deleting Them And Re-Uploading

    Automatically replace uploaded image with smaller one in WordPress

  6. Ian Dunn
    Plugin Author

    Posted 1 year ago #

    Version 1.1 doesn't require modifying Core anymore.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Overwrite Uploads
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic