setup.mediaPathRawToString = function(rawPath:ImagePath){
    if(typeof rawPath === "string")
        return rawPath;
    if(Array.isArray(rawPath)){
        const string:string = rawPath[0].toString();
        const max:number = +rawPath[1];
        return string.replace('#',rand(1,max).toString());
    }
    console.error('Unsupported type in setup.mediaPathRawToString:',rawPath,typeof rawPath);
}

setup.mediaPath = function(rawPath:string){
    rawPath = setup.mediaPathRawToString(rawPath);
    if(rawPath.substring(0,6) == 'https:' || rawPath.substring(0,5) == 'http:')
        return rawPath;

    let path = State.variables.media_path + rawPath;
	return path;
}

setup.mediaPathImage = function(rawPath:string){
    rawPath = setup.mediaPathRawToString(rawPath);
    if(rawPath.substring(0,6) == 'https:' || rawPath.substring(0,5) == 'http:')
        return rawPath;

    let path = State.variables.media_path + rawPath;
    if(setup.isWebVersion)
		path = path.replace(path.split('.').pop(),'webp');
	return path;
}