Forums

Join
bbPress Support ForumsInstallationextract image from post content

Info

Tags

extract image from post content

  1. 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

  2. What are you using this for?

  3. You must log in to post.