function wp_rp_img_html_to_post_id($html, &$matched_html = null)
{
    $attachment_id = 0;
    // Look for an <img /> tag
    if (!preg_match('#' . wp_rp_get_tag_regex('img') . '#i', $html, $matches) || empty($matches)) {
        return $attachment_id;
    }
    $matched_html = $matches[0];
    // Look for attributes.
    if (!preg_match_all('#class=([\'"])(.+?)\\1#is', $matched_html, $matches) || empty($matches)) {
        return $attachment_id;
    }
    $img_class = $matches[2][0];
    if (!$attachment_id && !empty($img_class) && false !== strpos($img_class, 'wp-image-')) {
        if (preg_match('#wp-image-([0-9]+)#i', $img_class, $matches)) {
            $attachment_id = absint($matches[1]);
        }
    }
    return $attachment_id;
}
function wp_rp_img_html_to_post_id($html, &$matched_html = null)
{
    $attachment_id = 0;
    // Look for an <img /> tag
    if (!preg_match('#' . wp_rp_get_tag_regex('img') . '#i', $html, $matches) || empty($matches)) {
        return $attachment_id;
    }
    $matched_html = $matches[0];
    // Look for attributes.
    if (!preg_match_all('#class=([\'"])(.+?)\\1#is', $matched_html, $matches) || empty($matches)) {
        return $attachment_id;
    }
    $attr = array();
    foreach ($matches[1] as $key => $attribute_name) {
        $attr[$attribute_name] = $matches[2][$key];
    }
    if (!$attachment_id && !empty($attr['class']) && false !== strpos($attr['class'], 'wp-image-')) {
        if (preg_match('#wp-image-([0-9]+)#i', $attr['class'], $matches)) {
            $attachment_id = absint($matches[1]);
        }
    }
    return $attachment_id;
}