brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: IMAGE_EDIT_OVERWRITE stops WordPress from piling up edited image copies

WordPress
~/tips/tip-wordpress-image-edit-overwrite

define( 'IMAGE_EDIT_OVERWRITE', true );

Keeps one set of edited image files instead of a new set every time you crop.

The image editor in the media library is handy for a quick crop or rotate. Each save writes a complete new set of files, though.

define( 'IMAGE_EDIT_OVERWRITE', true );

By default, every time you edit an image WordPress creates the full image plus all its thumbnail sizes again, with a suffix like -e1732960000000 in the name. The earlier edits stay on disk. Restore the original, and those edits still stay. Crop a photo five times while you look for the right frame and you have five sets of files.

With the constant set to true, only one set of edits is kept. A new edit deletes the previous edited files, and restoring the original removes the edits from the server. The original upload is never touched in either case, so you can always go back.

I find it a sensible default for any site where people tweak images in the dashboard. It only affects edits made after you add it, so old leftover copies remain. And be careful if a post links straight to an edited file name, for example in a custom HTML block: once a newer edit deletes that file, the link breaks. Images inserted through the normal blocks update fine.

Further reading: wp-config: Cleanup image edits

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link