function url_to_link_or_image($text) {
$obrazek = "ADRES DO OBRAZKA";
$text = preg_replace('#(^|[\n ])((http|https|ftp|ftps)://[\w\#$%&~/.\-;:=,?@\[\]\(\)+]*)#sie', "'\\1
'", $text);
$text = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]\(\)+]*)#sie", "'\\1'.trimlink('\\2', 20).(strlen('\\1')>
'", $text);
return $text;
}