/**
 * Check the existense of file [th_databaseid-rectypeid.png].
 * If not found - creates stub image with text
 *
 * return URL to thumbnail file
 *
 * @param mixed $rectypeID
 */
function getRectypeThumbURL($rectypeID)
{
    $name = "th_" . $rectypeID . ".png";
    $filename = HEURIST_ICON_DIR . "thumb/" . $name;
    if (!file_exists($filename)) {
        //create the stub image with text - rectypeID
        $img = make_file_image($rectypeID, 75, 48);
        imagepng($img, $filename);
    }
    return HEURIST_ICON_SITE_PATH . "thumb/" . $name;
}
             case 'image/jpeg':
             case 'jpeg':
             case 'jpg':
                 $img = @imagecreatefromjpeg($filename);
                 break;
             case 'image/gif':
             case 'gif':
                 $img = @imagecreatefromgif($filename);
                 break;
             case 'image/png':
             case 'png':
                 $img = @imagecreatefrompng($filename);
                 break;
             default:
                 $desc = '***' . strtoupper(preg_replace('/.*[.]/', '', $file['ulf_OrigFileName'])) . ' file';
                 $img = make_file_image($desc);
                 //from string
                 break;
         }
     }
     restore_error_handler();
 } else {
     if ($file['ulf_ExternalFileReference']) {
         if ($type_media == 'image') {
             //$type_source=='generic' &&
             //@todo for image services (panoramio, flikr) take thumbnails directly
             $img = get_remote_image($file['ulf_ExternalFileReference']);
         } else {
             if ($type_source == 'youtube') {
                 $url = $file['ulf_ExternalFileReference'];
                 $youtubeid = preg_replace('/^[^v]+v.(.{11}).*/', '$1', $url);