public function relativeToAbsolute($string, $base)
    {
        $matches = preg_split('#(<(a|img)\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
        $old     = $matches;

        foreach ($matches as &$match) {
            if (preg_match('/<(a|img)\b/', $match) && !preg_match('/(?:http|#|mailto)/', $match)) {
                $match = preg_replace('/^([^"]+")([^"]+)/', '$1' . $base . '$2', $match);
            }
        }

        $string = str_replace($old, $matches, $string);
        return $string;
    }