Moving to HTTPS on WordPress: Images Within Legacy Content


Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 12 in /home/customer/www/bmorecreativeinc.com/public_html/wp-content/plugins/gistpress-develop/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag svg invalid in Entity, line: 14 in /home/customer/www/bmorecreativeinc.com/public_html/wp-content/plugins/gistpress-develop/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag path invalid in Entity, line: 15 in /home/customer/www/bmorecreativeinc.com/public_html/wp-content/plugins/gistpress-develop/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag template invalid in Entity, line: 28 in /home/customer/www/bmorecreativeinc.com/public_html/wp-content/plugins/gistpress-develop/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag svg invalid in Entity, line: 30 in /home/customer/www/bmorecreativeinc.com/public_html/wp-content/plugins/gistpress-develop/includes/class-gistpress.php on line 466

Warning: DOMDocument::loadHTML(): Tag path invalid in Entity, line: 31 in /home/customer/www/bmorecreativeinc.com/public_html/wp-content/plugins/gistpress-develop/includes/class-gistpress.php on line 466

This information is straight out of an excellent post on CSS-Tricks about moving to HTTPS on WordPress, but the information is so valuable that I felt it bears repeating.

Source attributes for images within WordPress are fully qualified HTTP URLs. In order to eliminate the explosion of mixed content warnings, after a site has been migrated to HTTPS, run the following SQL statements to convert references to http:// to the protocol relative //

// image src in double quotes
UPDATE `wp_posts`
SET `post_content` = ( REPLACE (`post_content`, 'src="http://', 'src="//') )
WHERE INSTR(`post_content`, 'jpeg') > 0
OR INSTR(`post_content`, 'jpg') > 0
OR INSTR(`post_content`, 'gif') > 0
OR INSTR(`post_content`, 'png') > 0;
// image src in single quotes
UPDATE `wp_posts`
SET `post_content` = ( REPLACE (`post_content`, "src='http://", "src='//") )
WHERE INSTR(`post_content`, 'jpeg') > 0
OR INSTR(`post_content`, 'jpg') > 0
OR INSTR(`post_content`, 'gif') > 0
OR INSTR(`post_content`, 'png') > 0;