php - Wordpress URL and wp_get_attachment_image_src - http vs https -
in wordpress settings, wordpress url (which used lot of resource urls) requires hardcode either http://
or https://
in url. results in issues insecure parts being loaded on secure site or vice versa. how handle this?
example:
//the wordpress url setting (in settings->general) http://example.net //an image source (this http://example.net/images/myimage.png) $imagesource = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), "myimage" ); ?><img src="<?php echo $imagesource; ?>" .?<?php ... ?>
if user visiting https://example.net
, image still loaded non-secure "http".
how fix site in https loads (not wp_get_attachment_image_src
) in https , vice-versa?
you have replace http in url string.
$imagesource = wp_get_attachment_image_src( get_post_thumbnail_id( $post->id ), "myimage" ); $output = preg_replace( "^http:", "https:", $imagesource ); echo $output;
you add filter required functions (for example: add_filter( 'template_directory_uri', function( $original )
... use ssl.
Comments
Post a Comment