Example #1
0
    private string GetEmbedCode(string path, string filename)
    {
        SiteFile file = SiteFiles.GetFile(path, filename);

        if (file != null)
        {
            if (!GlobalSettings.IsImage(filename))
            {
                return(string.Format("<a href=\"{0}\">{1}</a>", FileStorageProvider.GetGenericDownloadUrl(file.File), filename));
            }
            else
            {
                int width  = 200;
                int height = 200;
                try
                {
                    width = int.Parse(this.txtWidth.Text);
                }
                catch { }
                try
                {
                    height = int.Parse(this.txtHeight.Text);
                }
                catch { }

                return(GlobalSettings.ResizeImageHtml(SiteUrlManager.GetResizedImageUrl(file.File, width, height), width, height, false));
            }
        }
        else
        {
            return(string.Empty);
        }
    }
Example #2
0
 /// <summary>
 /// 获取默认图像
 /// </summary>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <returns></returns>
 public string GetDefaultImageUrl(int width, int height)
 {
     if (width == 0 || height == 0)
     {
         if (File != null)
         {
             return(FileStorageProvider.GetGenericDownloadUrl(File));
         }
         else
         {
             return(SiteUrlManager.GetNoPictureUrl());
         }
     }
     else
     {
         if (File == null)
         {
             return(SiteUrlManager.GetNoPictureUrl(width, height));
         }
         else
         {
             return(SiteUrlManager.GetResizedImageUrl(File, width, height));
         }
     }
 }