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 regenerate --only-missing fixes images after a theme change

Media
~/tips/tip-wordpress-media-regenerate-only-missing

wp media regenerate --only-missing --yes

Creates only the missing image sizes after a theme change instead of redoing every thumbnail.

Switch themes and half your images look wrong. The new theme wants sizes that WordPress never made.

WordPress creates its thumbnail sizes when an image is uploaded. A new theme can register sizes that did not exist then. wp media regenerate rebuilds them, and the --only-missing flag makes it skip everything that is already fine.

wp media regenerate --only-missing --yes

Without attachment IDs it works on the whole library and asks for confirmation first. The --yes flag skips that question. You can also name the size: --image_size=large, and repeat the flag for more than one size.

By default the command deletes the old thumbnails before it makes new ones. That is the reason to be careful. If other sites or posts link straight to the old thumbnail files, add --skip-delete to keep them. The plain command without --only-missing redoes every image, which is slow on a big library.

The caveat is the obvious one: take a backup of the uploads folder first. Regenerating is hard on disk and CPU, so I would run it at a quiet time and not in the middle of the afternoon.

Further reading: wp media regenerate (WP-CLI command reference), On this site: wp option list –autoload=on –format=total_bytes shows what every page load drags along, On this site: –skip-plugins and –skip-themes get WP-CLI working on a broken site

More Media tips avconvert -s clip.mov -o clip-720.m4v -p Preset1280x720 avmediainfo holiday.mov ffmpeg -f lavfi -i testsrc2=size=1280×720:rate=30 \ rpicam-still --timeout 30000 --timelapse 2000 -o timelapse/image%04d.jpg All Media tips (5) All topics

Link