In WordPress, when using Featured Image how do I get just the URI to the image? Not the whole bit of HTML?
-
I have read this: http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature I can add an image. I can display an image. But I also have a plugin that I want to access the Feature Image image - sans all the HTML - and email out the URL for the image. How can I get the image's location without all the HTML? Note: There's a bit more to the plugin than just that but for the sake of this discussion it's enough.
-
Answer:
You can use the follwing to retrieve URL for an attachment thumbnail. $thumb_url = wp_get_attachment_thumb_url( $post_id );
Azizur Rahman at Quora Visit the source
Other answers
a better answer $url = wp_get_attachment_image_src( get_post_thumbnail_id( $post_ID ), 'featured' ); (replace 'featured' with the size of the image you want to have) <img src="<?php echo $url[0] ?>" width="<?php echo $url[1] ?>" height="<?php echo $url[2] ?>" /> I've included the height and width. Notice the wp_get_attachment_image_src returns an array which has SRC WIDTH and HEIGHT. Also notice that with this command you can get any size of image, not just the default thumbnail size. You could of course use it like <div style="background: transparent url(<?php echo $url[0] ?>) no-repeat center center"></div>
Andy Killen
Related Q & A:
- How can I get custom fields in wordpress?Best solution by Stack Overflow
- How do I get and Icon for my picture, not just my avatar?Best solution by Yahoo! Answers
- How would I get satellite in my whole apartment complex?Best solution by dslreports.com
- My font just got real small how do I get it back to the regular size?Best solution by answers.microsoft.com
- How do I get an image copyrighted?Best solution by ehow.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.