• Code from header.php in 20/11 theme.

    // 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, 'post-thumbnail' );

    I’m trying to figure out one of the conditions in the above code. This code is from the header.php file in the 20/11 theme. It’s the line that starts with “$image = wp_get_attachment_image_src(…”. I’m trying to figure out what this whole condition is asking. What’s throwing me is the array values passed into the function. From what I understand, the wp_get_attachment_image_src() function [I’m going to abbreviate this function to “get_img_src()” from now on] returns an array of 3 values — the src of the requested image file, and the width and height values of the returned image file.(Is this correct?) It looks like the code above is using the “get_img_src()” function to request the version of the attachment file that has a size of ($header_image_width)x($header_image_width). It looks like $header_image_width has been set in the functions.php file to an unfiltered value of 1000px. My question is 1.)Am I interpreting the “get_img_src()” function call correctly? and 2.)Why is the code asking for this particular version of the image? (a 1000×1000 px version of the post thumbnail file, which almost certainly has not been created by WP on upload) Overall, I’m trying to figure out what this whole string of “AND” conditions is trying to test for and why.

    I’m sorry for the lengthy question. If you have any thoughts, I’d be pleased to here them.

    Thanks, Mike H.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘TwentyEleven Header Question’ is closed to new replies.