Advertisement
keha76

WordPress Get Featured Image URL

Mar 14th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Get the featured image URL.
  5.  *
  6.  * @param string|array $size // Name of image size or an array; array( 300, 400 )
  7.  * @param boolean $icon Use a media icon to represent the attachment.
  8.  * @return string|boolean
  9.  * @author Kenth Hagström
  10.  * @version 1.0
  11.  * @license GPL
  12.  */
  13. function keha76_get_image_url( $size = 'thumbnail', $icon = false ) {
  14.     global $post;
  15.     $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size, $icon );
  16.     if( $src ) {
  17.         echo $src[ 0 ];
  18.     }
  19.     return false;
  20. }
  21.  
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement