Support » Plugin: Cimy Header Image Rotator » View default header image while images are loading

  • Hi Marco,

    I didn’t like seeing “Loading images…” and a blank header while the header images were loading. So instead, I display the default header image in the theme until the rest of the images are loaded. Then I modified your plugin to start it’s rotation using the default header image so there’s no unfaded transition between the on-page-load header image and the first image the plugin displays.

    In keeping with your plugin’s integration with the WordPress Custom Header functionality this is automatic and conditional on a header image being set and the plugin loading the pictures from “Theme’s uploaded”.

    If this makes sense to you, you’re welcome to the changes I made.

    Regards

    http://wordpress.org/plugins/cimy-header-image-rotator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • max_Q,
    Can you post the code to do this?

    Replace the else if on lines 354 and 355 with:

    else if ($cimy_hir_curr_options['configs'][$id]['images_source'] == 'theme_uploaded') {
    			$img_array = hir_theme_images_array_to_local_array(get_uploaded_header_images());
    			$header_image = get_header_image();
    			if ( ! empty( $header_image ) ) {
    				if( ( $img_key = array_search ( $header_image, $img_array ) ) !== false ) {
    					unset( $img_array[$img_key] );
    					$img_array = array_values( $img_array );
    				}
    				array_unshift( $img_array, $header_image );
    			}
    		}

    Then, put this in your theme header file where you want the header image to be:

    <?php
    				// Check to see if there is a default header image. If there is, display it while the image rotator loads the rest of the images. Otherwise just display "Loading images..."
    				$header_image = get_header_image();
    				if ( ! empty( $header_image ) ) :
    			?>
    <div id="cimy_div_id_0"><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php echo $header_image; ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" /></a></div>
    			<?php
    				else :
    			?>
    <div id="cimy_div_id_0">Loading images...</div>
    			<?php
    				endif; // end check for existence of default header image
    			?>

    No guarantee of the quality of the code, but it works for me. YMMV. Enjoy.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘View default header image while images are loading’ is closed to new replies.