Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyskoczilova/d50c4db8235128cebe38d2a411285607 to your computer and use it in GitHub Desktop.
Save vyskoczilova/d50c4db8235128cebe38d2a411285607 to your computer and use it in GitHub Desktop.
WordPress DB: Images within legacy content
/*
WordPress DB: Images within legacy content
source: https://css-tricks.com/moving-to-https-on-wordpress/
author: Jason Witt (http://jawittdesigns.com/)
*/
/* 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;
/* 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;
/* Custom fields */
UPDATE wp_postmeta
SET meta_value=(REPLACE (meta_value, 'iframe src="http://','iframe src="//'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment