Skip to:
Content
Pages
Categories
Search
Top
Bottom

extract image from post content


  • psycheangels
    Member

    @psycheangels

    function get_post_img(){
    global $bbdb;
    $topic_id_ft = get_topic_id(); //topic id for getting text of first post of the topic
    $first_post = (int) $bbdb->get_var("SELECT post_id FROM $bbdb->posts WHERE topic_id = $topic_id_ft ORDER BY post_id ASC LIMIT 1");
    $content = substr(strip_tags(strip_shortcodes(get_post_text($first_post))),0);
    preg_match('/[img](.*?)[/img]/i', $content, $matches);
    $src = $matches[1];
    echo $src;
    }

    modified from here http://bbpress.org/forums/topic/show-a-snippet-of-the-post-under-the-topic-title#post-39260

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar