hasAttribute('alt')) { $alt = $token->getAttribute('alt'); } else { // try to get the alternative from the URL $alt = rtrim($text, '/'); $alt = strrchr($alt, '/'); if (false !== strpos($alt, '.')) { $alt = substr($alt, 1, strpos($alt, '.') - 1); } } return "\"{$alt}\"""; } }