Advertisements

wp_get_attachment_thumb_url

Definition:
function wp_get_attachment_thumb_url( $post_id = 0 ) {}

Retrieve URL for an attachment thumbnail.

Parameters

  • int $post_id: Attachment ID

Return values

returns:False on failure. Thumbnail URL on success.

Defined filters

  • wp_get_attachment_thumb_url
    apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID )

Source code

function wp_get_attachment_thumb_url( $post_id = 0 ) {

	$post_id = (int) $post_id;

	if ( !$post =& get_post( $post_id ) )

		return false;

	if ( !$url = wp_get_attachment_url( $post->ID ) )

		return false;



	$sized = image_downsize( $post_id, 'thumbnail' );

	if ( $sized )

		return $sized[0];



	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )

		return false;



	$url = str_replace(basename($url), basename($thumb), $url);



	return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );

}

3691

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: