• I want to get some info from the post content betore access, and access to some other data table, but I cannot find how to get the content, I used the $_POST[‘content’] but it don’t work, who can tell me how to do, please

Viewing 1 replies (of 1 total)
  • Thread Starter joyeeyu

    (@joyeeyu)

    function get_post_1st_img ($the_content=”) {
    if(strlen($the_content)) {

    // use regex to find the src of the image

    preg_match(“/<img src\=(‘|\”)(.*)(‘|\”) .*( |)\/>/”, $the_content, $matches);
    if(!$matches) {
    preg_match(“/<img class\=\”.*\” title\=\”.*\” src\=(‘|\”)(.*)(‘|\”) .*( |)\/>/U”, $the_content, $matches);
    }
    $the_image_src = $matches[2];
    $frags = preg_split(“/(\”|’)/”, $the_image_src);
    if(count($frags)) {
    $the_image_src = $frags[0];
    }

    // if src found, then create a new img tag
    // if the src starts with http/https, then strip out server name

    if(strlen($the_image_src) && preg_match(“/^(http(|s):\/\/)/”, $the_image_src)) {
    $the_image_src = preg_replace(“/^(http(|s):\/\/)/”, ”, $the_image_src);
    $frags = split(“\/”, $the_image_src);
    array_shift($frags);
    $the_image_src = ‘/’ . join(“/”, $frags);
    }
    return $the_image_src;
    }
    }

    this function is working,

    but
    img = get_post_1st_img ($_REQUEST[‘CONTENT’])

    does not work in custom meta panel, Why?

Viewing 1 replies (of 1 total)
  • The topic ‘How can I get the post content before access to database’ is closed to new replies.