• w3inet

    (@w3inet)


    Hi I have noticed that the header images are not showing any text in the alt tags. I have found the function in functions.php as below but can’t figure what i need to put in the alt tags to get them to show. Can anyone please advise?

    function bavotasan_header_images() {
    	global $post;
    	$post_id = ( is_attachment() && isset( $post->post_parent ) ) ? $post->post_parent : get_queried_object_id();
    	$custom_image = ( is_singular() || get_option( 'page_for_posts' ) == $post_id || is_attachment() ) ? get_post_meta( $post_id, 'arcade_basic_custom_image', true ) : '';
    
    	if ( $custom_image ) {
    		echo '<img src="' . esc_url( $custom_image ) . '" alt="" class="header-img" />';
    	} else {
    		if ( $header_image = get_header_image() ) :
    			?>
    			<img class="header-img" src="<?php header_image(); ?>" alt="<?php echo( get_post_meta( $post_id, 'meta_value', true ) ); ?>" />
    			<?php
    		endif;
    	}
    }

    Thanks in advance.
    Dave.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter w3inet

    (@w3inet)

    In the original code the alt tags are empty. The code in the alt tags above is one that I tried but it did not work. Sorry for any confusion. I basically need to know the correct code to put there.

    I’ve left the ALT tag blank for the image since it is used as a background image. With an ALT tag, hovering over any part would bring up the tag.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Alt tags empty on header image’ is closed to new replies.