Database » Change image URL 🖼️ in WordPress database

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';
See also  How to get WordPress image link from the media ID

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.