• Default code for header image in TwentyTen is
    <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />

    Now I wish to get header image description and use it for ALT tag.

    The question is: How to get header image description? In functions.php I added this:

    'footonsand' => array(
    			'url' => '%s/images/headers/sand_and_foot.jpg',
    			'thumbnail_url' => '%s/images/headers/sand_and_foot-thumbnail.jpg',
    			'description' => __( 'Sand and Foot by Aleksandar Urošević', 'twentyten' )
    		),

    and I wish to get this description Sand and Foot by Aleksandar Urošević to some string, for example to $alt, and then echo $alt to page.

    TIA

Viewing 2 replies - 16 through 17 (of 17 total)
  • urkekg, you did say this is a quick and dirty solution, but nontheless I think this is a poor way to solve the problem. If the Header Images can’t supply the description, then its better not to use header images. Putting content into the functions.php file just seems wrong, and I certainly can’t expect a client to go adding arrays to the functions file.

    I solved my issue in a different way: I removed the header image code from my header.php file and replaced it with a gallery shortcode. This does everything I need.

    The header file still looks for a Featured Image first, and its easy to load the description from a featured image if its there.

    If there is no featured image, then the hearder runs the gallery shortcode. I can tell it to load just a single image (using the Gallery Extended plugin) and I can specify orderby = random. Image size is full.

    The gallery puts the description in the title tag, and I also styled the caption to show (I’m using this as a photo credit). The only problem I still have here is that it insists on linking the image. You can see this method working in the Maureen Whiting site:
    http://maureenwhitingco.org/

    No header image, just a random one-image gallery!

    U don’t need to blame me, I’m not WP core developer, just common user 🙂

    Actualy, if U don’t want to hack funtions.php then simply set post thumbnail for every post and page, and U’ll get description from media library, and header image will not be used at all. U can even hack header.php to use thumbnail from latest post on index page for header image.

Viewing 2 replies - 16 through 17 (of 17 total)

The topic ‘Get header image description to string’ is closed to new replies.