WordPress.org

Ready to get started?Download WordPress

Forums

header image is not 'SSL aware' (2 posts)

  1. photocurio
    Member
    Posted 1 year ago #

    With a little fussing, I've got every component of this site delivered by https:
    https://indigofirestudio.com
    —except the header image. I thought this was fixed years back. There is a 2 year old ticket on core trac that has a patch to "Make get_header_image() ssl-aware". But its still an issue.

    This is the code that calls the header image. I copied it from the twenty eleven theme.

    <?php
    // Check to see if the header image has been removed
    	$header_image = get_header_image();
    	if ( $header_image ) :
    // Compatibility with versions of WordPress prior to 3.4.
    	if ( function_exists( 'get_custom_header' ) ) {
    // We need to figure out what the minimum width should be for our featured image.
    // This result would be the suggested width if the theme were to implement flexible widths.
    	$header_image_width = get_theme_support( 'custom-header', 'width' );
    	} else {
    		$header_image_width = HEADER_IMAGE_WIDTH;
    	}
    ?>
    <?php
    // The header image
    // Check if this is a post or page, if it has a thumbnail, and if it's a big one
    	if ( is_singular() && has_post_thumbnail( $post->ID ) &&
    	( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
    	$image[1] >= $header_image_width ) :
    // Houston, we have a new header image!
    	echo get_the_post_thumbnail( $post->ID, 'header' );
    	else :
    // Compatibility with versions of WordPress prior to 3.4.
    	if ( function_exists( 'get_custom_header' ) ) {
    		$header_image_width  = get_custom_header()->width;
    		$header_image_height = get_custom_header()->height;
    	} else {
    		$header_image_width  = HEADER_IMAGE_WIDTH;
    		$header_image_height = HEADER_IMAGE_HEIGHT;
    	}
    ?>
    	<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="Indigo Fire Studio" class="header-image" />
    	<?php endif; // end check for featured image or standard header ?>
    	<?php endif; // end check for removed header image ?>
  2. photocurio
    Member
    Posted 1 year ago #

    This should be fixable with a filter that changes the absolute url of the header image to a relative url. I've tried putting this in my functions file (and several variations of it):

    function fix_header_image_ssl($url) {
        $url = get_theme_mod( 'header_image', $default );
    	$url = str_replace( 'http://mywebsite.com', '', $url );
    	return $url;
    	}
    add_filter('header_image', 'fix_header_image_ssl', 10, 1);

    But the absolute url remains. Is this filter targeting the wrong function?

Topic Closed

This topic has been closed to new replies.

About this Topic