CBPTaskResult :: ConvertBCodeImageTag: Bitrix method

      
<?php 
//  CBPTaskResult :: ConvertBCodeImageTag()
//  /dist/bitrix/modules/bizproc/classes/general/taskservice.php:810

    
function ConvertBCodeImageTag($url "")
    {
        if (
is_array($url))
            
$url $url[1];
        
$url trim($url);
        if (
strlen($url) <= 0)
            return 
"";

        
$extension preg_replace("/^.*\.(\S+)$/".BX_UTF_PCRE_MODIFIER"\\1"$url);
        
$extension strtolower($extension);
        
$extension preg_quote($extension"/");

        
$bErrorIMG False;

        if (
preg_match("/[?&;]/".BX_UTF_PCRE_MODIFIER$url))
            
$bErrorIMG True;
        if (!
$bErrorIMG && !preg_match("/$extension(\||\$)/".BX_UTF_PCRE_MODIFIER"gif|jpg|jpeg|png"))
            
$bErrorIMG True;
        if (!
$bErrorIMG && !preg_match("/^((http|https|ftp)\:\/\/[-_:[email protected]]+)*(\/[-_+\/=:[email protected]%]+)$/i".BX_UTF_PCRE_MODIFIER$url))
            
$bErrorIMG True;

        if (
$bErrorIMG)
            return 
"[img]".$url."[/img]";

        return 
'<img src="'.$url.'" border="0" />';
    }