Fixing external image urls

Since the request is sending to the blogspot server, no .htaccess wont wont.

You could filter your post content output:

add_filter('the_content', function($the_content) {
    return str_replace('/s400','/s1600',$the_content);
});

Or you could edit modify the database

global $wpdb;

$wpdb->query("UPDATE $wpdb->posts SET `post_content` = REPLACE(`post_content`,'/s400','/s1600');"); 

Or do it in mysql

UPDATE wp_posts SET `post_content` = REPLACE(`post_content`,'/s400','/s1600';

assuming wp_posts is your posts table.

Or you could use wpcli

wp search-replace '/s400' '/s1600'

If you modify the database tho any of the methods, be sure to always backup the database before hand.


(Before anyone else dismisses my answer, please note that what I’ve provided would be an answer to your question, but it’s a bandaid fix to the real problem: the images aren’t in WordPress and probably should be.

Leave a Comment