humanmade/replace-files

Plugin which allows you to upload a replacement for an existing attachment.

Installs: 1 151

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 25

Forks: 2

Open Issues: 2

Type:wordpress-plugin

1.0.0 2019-08-13 17:11 UTC

This package is not auto-updated.

Last update: 2024-11-29 18:16:37 UTC


README

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:

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',
	]);
});