Skip to content

Instantly share code, notes, and snippets.

@krishna19
Forked from thomasmb/ssl-support.php
Created December 14, 2016 13:06
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 krishna19/010e8e02a6a78b89999d3998f20c4266 to your computer and use it in GitHub Desktop.
Save krishna19/010e8e02a6a78b89999d3998f20c4266 to your computer and use it in GitHub Desktop.
Simple filter for adding https support to wp_get_attachment_url in WordPress
<?php
add_filter( 'wp_get_attachment_url', function( $url, $id ){
if( is_ssl() )
$url = str_replace( 'http://', 'https://', $url );
return $url;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment