[wp-hackers] Extract first image from a post

Malaiac malaiac at gmail.com
Sun Nov 23 22:35:10 GMT 2008


2008/11/23 Alex Hempton-Smith <hempsworth at googlemail.com>:
> Okay, after some searching I've managed to get it working with some very
> complicated (for me anyway) code, it goes completely over my head but at
> least it works!
> For anybody who's interested:
>
> function teaserimg()
> {
>
>   ob_start();
>
>       the_content();
>
>       $html = ob_get_contents();
>
>   ob_end_clean();

function teaserimg() {
  global $post;
  $html = $post->post_content;

works too if in the loop


More information about the wp-hackers mailing list