Database – SQL query to rewrite all media URLs ending with .webp

I have manually converted all the media files to .webp within the ‘Uploads’ folder, I have maintained the folder structure, each .webp image resides in the same folder as its predecessor. How do I convert all media links to end with .webp so that they now point to converted images?

See example below:

From this
https://example.com/wp-content/uploads/2019/09/image.jpg
https://example.com/wp-content/uploads/2020/02/image.png
https://example.com/wp-content/uploads/2022/06/image.gif

To this
https://example.com/wp-content/uploads/2019/09/image.webp
https://example.com/wp-content/uploads/2020/02/image.webp
https://example.com/wp-content/uploads/2022/06/image.webp

I’ve tried to find a SQL query that I can run to rewrite all media links in the database without success.

Leave a Comment