All About WordPress Thumbnail Image

  1. Display Image with image Tag with image size
/* Default Image Size : */
the_post_thumbnail(); // without parameter -> 'post-thumbnail'
the_post_thumbnail( 'thumbnail' ); // Thumbnail (default 150px x 150px max)
the_post_thumbnail( 'medium' ); // Medium resolution (default 300px x 300px max)
the_post_thumbnail( 'large' ); // Large resolution (default 640px x 640px max)
the_post_thumbnail( 'full' ); // Full resolution (original size uploaded)
the_post_thumbnail( array(100, 100) ); // Other resolutions
<?php
 echo get_the_post_thumbnail( $post->ID, 'image_size_name' );
?>
Output : <img src="image_path" width="" height="" alt=""/>

2.Display Image with image Tag with image size

<?php
 $image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'large_image' );
?>
<img src="<?php echo $image_url[0];?>" alt=""/>

3.Featured image title

<?php
 $thum_post = wp_get_single_post( get_post_thumbnail_id($post->ID), 'OBJECT' ); 
?>
<img src="image-path" alt="" title="<?php echo $thum_post->post_title; ?>"/>
Advertisements

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