Created
February 26, 2017 22:11
-
-
Save wpexplorer/e3e7c4abd2937bb424ad8f485af4bf3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wpex_honor_ssl_for_attachments( $url ) { | |
if ( is_ssl() ) { | |
$upload_info = wp_upload_dir(); | |
if ( isset( $upload_info[ 'baseurl' ] ) && strpos( $upload_info[ 'baseurl' ], 'https' ) ) { | |
$http = site_url( FALSE, 'http' ); | |
$https = site_url( FALSE, 'https' ); | |
return str_replace( $http, $https, $url ); | |
} | |
} | |
return $url; | |
} | |
add_filter( 'wp_get_attachment_url', 'wpex_honor_ssl_for_attachments' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment