Kindeditor 遠程圖片寬度自動適應

來源:互聯網
上載者:User

很多客戶對kindeditor編輯器中的圖片操作不熟,上傳圖片完成後,不注意圖片寬度問題,往往造成圖片寬度超出內容地區,使得一部分圖片被隱藏,不友好。

為解決這個問題,讓上傳的圖片自動適應內容地區的寬度,修改了下upload_json.ashx代碼,很簡單如下:

//大概是91行的位置,圖片儲存完成,操作imgFile.SaveAs(filePath);                String fileUrl = saveUrl + newFileName;        Hashtable hash = new Hashtable();        hash["error"] = 0;        hash["url"] = fileUrl;        #region 計算圖片寬度        System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(filePath);        int _width = bmp.Width;        bmp.Dispose();        if (_width > 930)//你內容地區的寬度        {            hash["width"] = "100%";        }        #endregion        context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");        context.Response.Write(JsonMapper.ToJson(hash));        context.Response.End();

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.