2013-01-16 15 views
6

Devo ottenere la sorgente dell'immagine dal codice qui sotto.

$thumburl = get_the_post_thumbnail($post->ID); 

Qui sto ricevendo

<img width="325" height="202" src="http://localhost/TantraProjects/Border-fall/Repo/WebApp/wp-content/uploads/2012/12/film.png" class="attachment-post-thumbnail wp-post-image" alt="film" title="film"> 

voglio ottenere questa parte.

"http://localhost/TantraProjects/Border-fall/Repo/WebApp/wp-content/uploads/2012/12/film.png" 

Come posso ottenere la fonte?

risposta

24
$post_thumbnail_id = get_post_thumbnail_id($post->ID); 
$post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id); 
+0

ha funzionato. molto bella. Grazie. ho impiegato ore per ottenere questo. – ejobity

-2

lì signore,

$post_thumbnail_url = wp_get_attachment_thumb_url($post->ID); 
+0

Questo non funzionerà, avrete bisogno di un ID allegato come argomento al posto dell'ID post che avete fornito. Vedi: http://codex.wordpress.org/Function_Reference/wp_get_attachment_thumb_url –