I'm using timthumb.php and need to be able to get the url of the featured image of a post, when I use functions like the_post_thumbnail
it does more than just the url.
Here is the code so, the capital letters is where I need to insert the exact url, any help would be great, thanks.
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<img src="<?php bloginfo('template_url'); ?>/wp-content/themes/limerickfc/timthumb.php?src=<?php URL OF FEATURED IMAGE ?>&h=760&width=474" alt="" title="<?php the_title(); ?>" />
</a>
If your "thumbnail" images are large enough to do what you need:
<?php wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>
Otherwise you'll need to go for something like:
<?php $src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), array(300, 300), false, ''); echo $src[0]; ?>
EDIT: The array(300, 300)
bit is the image size you'd like to fetch. WP will substitute any image it has that is at least as large as what you asked for. You can also use 'thumbnail'
, 'medium'
, 'large'
or 'full'
to select one of the pre-configured sizes, as well as any name defined by add_image_size()
in your template or plugins.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With