Media Entity File Replace

Replace media files with the same name, instead of adding _1.

After installing the module, clear the cache and edit the form settings for media. Enable the Replace file field (place it under the file upload).

Drupal adds _1 to uploaded files to preserve references to the old files in revisions.

The changed file name also fixes caching issues, where a user may have the old version in their browser cache and not see the update until it expires.

The alt text is preserved while replacing the file, which is helpful when replacing an image with a different crop or size and the text is still relevant.

Media Entity File Replace widget

See issue for refreshing generated image styles after replacing the image.

Module tags
Tags