Skip to content

Instantly share code, notes, and snippets.

@ethanclevenger91
Created February 27, 2014 16:58
Show Gist options
  • Save ethanclevenger91/7904a5545979105fe691 to your computer and use it in GitHub Desktop.
Save ethanclevenger91/7904a5545979105fe691 to your computer and use it in GitHub Desktop.
Get secure thumbnail from Wordpress
function the_secure_post_thumbnail($size, $options) {
ob_start();
the_post_thumbnail($size, $options);
$thumbnail = ob_get_clean();
$secure_thumbnail = make_secure($thumbnail);
echo $secure_thumbnail;
}
function make_secure($url) {
$secure_url = $url;
if(is_ssl()) {
$secure_url = str_replace('http', 'https', $secure_url);
}
return $secure_url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment