I’ve been wanting to change the theme for a WordPress website that I’ve been using for blogging for many years. The problem is that the new theme has different full width image dimensions. To change each image for the thousands of blog posts individually will take way too much time.
SQL to Change WordPress Images in Thousands of Posts
In case this helps you in changing images for posts en-mass very quickly then here is the SQL I used in PHPMyAdmin for my MySQL database. This is essentially a ‘find and replace’ for all posts in my WordPress website. Wherever the old image is found, the SQL script replaces the HTML for the new image (hence the new image then shows in place of the old image).
Merely run the following SQL in PHPMyAdmin:
update `wp_posts` set `post_content` = replace(post_content,'<img src="https://example.com/wp-content/uploads/2018/12/old-image.png" alt="Your old image" width="350" height="220" class="alignright size-full wp-image-24786" />','<img src="https://example.com/wp-content/uploads/2019/01/new-image.png" alt="Your new image" width="1024" height="512" class="alignnone size-large wp-image-25400" />');