static string DefaultIconUrl(JsonPackage pkg)
{
var validImages = new List<string> {"screenshot.jpg", "screenshot.png", "theme.jpg", "theme.png"};
var pkgDir = pkg.PackageType == "Widget" ? "widgets" : "themes";
foreach (var img in validImages)
{
var url = string.Format("{0}{1}/{2}/{3}",
Utils.ApplicationRelativeWebRoot, pkgDir, pkg.Id, img);
var path = HttpContext.Current.Server.MapPath(url);
if (File.Exists(path)) return url;
}
if (pkg.PackageType == "Widget")
return Utils.ApplicationRelativeWebRoot + "pics/Widget.png";
return Utils.ApplicationRelativeWebRoot + "pics/Theme.png";
}