Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/humanmade/replace-files
https://github.com/humanmade/replace-files
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/humanmade/replace-files
- Owner: humanmade
- Created: 2017-07-07T01:36:27.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T14:49:11.000Z (12 months ago)
- Last Synced: 2024-06-22T05:25:32.916Z (3 months ago)
- Language: PHP
- Size: 29.3 KB
- Stars: 7
- Watchers: 25
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Replace Files
This plugin allows you to upload a replacement for an existing attachment.
## Cache Busting
Replacements use the same filename as the original, allowing existing links to continue working. However, this may require busting the cache to expose the new image. You can use the `replace_files.merge_replacement.replaced` action to handle this:
```php
add_action( 'replace_files.merge_replacement.replaced', function ( $post_id ) {
// Purge the server's cache.
wp_remote_request( wp_get_attachment_url( $post_id ), [
'method' => 'PURGE',
]);
});
```