I have a widget that works with my theme that expects images named in a certain way, slide1.png, slide2.png, etc…
However, when the user uploads their own images, named slide1.png, slide2.png, etc to the media library, rather than updating the images with the new ones, WordPress changes the names of the replacement images to slide11.png, slide22.png, etc
Can I set a filter in theme options that tells WP to overwrite existing images without changing the filenames?
Here is something i cooked up which was taken mainly from the plugin
Overwrite Uploads
but without the extra stuffI managed to make this work using a bit of @Bainternet’s Answer without hacking the core.
This other Q&A was helpful as well: query_posts: how to show all ‘meta_value’ containing a specific word?
The function
wp_unique_filename
has the filtersanitize_file_name
just at the beginning, so we can hook there and do the checking and removal of the duplicate attachment.I did basic localhost testings, please test it thoroughly before applying to a live site.