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: wp media image-size lists every thumbnail size WordPress creates

WordPress
~/tips/tip-wordpress-media-image-size

wp media image-size

Shows the registered image sizes with width, height and crop, so you see what each upload costs.

Each image you upload is saved in several sizes. Themes and plugins add their own, and the list grows without anyone noticing.

wp media image-size

The output is a table with name, width, height, crop and ratio for every size that is registered right now: the core ones like thumbnail, medium, medium_large and large, and whatever the active theme and plugins add. --format=count gives just the number, --format=csv is good for a spreadsheet.

This is the place I’d look when wp-content/uploads grows faster than it should. Ten registered sizes means up to ten extra files per upload, for every image larger than those sizes.

The list depends on what is loaded. Switch themes and sizes appear or disappear, but the files from the old theme stay on disk. Removing a size from the theme stops new files; it does not delete old ones.

The core sizes are under Settings > Media. Setting one to 0 by 0 stops WordPress from creating it for new uploads. After any change, wp media regenerate can rebuild the thumbnails, and that can take a long time on a big library.

Further reading: wp media image-size, add_image_size()

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 server --host=127.0.0.1 --port=8080 All WordPress tips (85) All topics

Link