Echo URL of large version of Featured Image

I use this plugin to echo the URL of a post’s featured image in the header:

<?php
/** Plugin Name: Post Thumbnail FB header */
function fb_header()
{
    // Not on a single page or post? Stop here.
    if ( ! is_singular() )
        return;

    $post_ID = get_queried_object_id();

    // We got no thumbnail? Stop here.
    if ( ! has_post_thumbnail( $post_ID ) )
        return;

    // Get the Attachment ID
    $att_ID = get_post_thumbnail_id( $post_ID );

    // Get the Attachment
    $att    = wp_get_attachment_image_src( $att_ID );

    printf(
         '<link rel="image_src" href="%s" />'
        ,array_shift( $att )
    );
}
add_action( 'wp_head', 'fb_header' );
?>

As it stands currently, it echo’s the featured image. I want it to echo the URL of the Large version of the featured image. How can I do this? Just to note that all my featured images have a large version…

Related posts

Leave a Reply

1 comment

  1. Use the second parameter of wp_get_attachment_image_src(): $size.

    $att    = wp_get_attachment_image_src( $att_ID, 'large-thumb' );
    

    or

    $att    = wp_get_attachment_image_src( $att_ID, array ( 900, 300 ) );
    

    The size is passed to image_downsize() and there to image_get_intermediate_size(). If $size is an array WordPress will search for the best match in existing images:

    // from wp-includes/media.php::image_get_intermediate_size()
    // get the best one for a specified set of dimensions
    if ( is_array($size) && !empty($imagedata['sizes']) ) {
        foreach ( $imagedata['sizes'] as $_size => $data ) {
            // already cropped to width or height; so use this size
            if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
                $file = $data['file'];
                list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
                return compact( 'file', 'width', 'height' );
            }