Change image URL in WordPress database

Many users choose to host their images on an external service to reduce the load on their hosting. If you are interested in doing this, you will only have to change the location of all the images that you have already uploaded.

To do this, you need to make two SQL queries in your database:

1. For images inside posts:

UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="//', 'src="//');

2. For images linked as attachments:

UPDATE wp_posts SET  guid = REPLACE (guid, '', '') WHERE post_type = 'attachment';

Was this post helpful?

Leave a Comment