Ueditor Baidu editor removes online image management (1/2)

Source: Internet
Author: User

Some time, we do not want the editor to have online management functions. For example, our message board certainly does not want other users to directly have online image management functions. How can we delete these functions, the following article introduces the online image management function for deleting Baidu editor and removing images.

Method

First, find image.html in dialogs/image /.

Delete Code

The Code is as follows: Copy code

<Span tabSrc = "imgManager"> <var id = "lang_tab_imgManager"> </var> </span>

Find

The Code is as follows: Copy code

If (id = "imgManager "){
List. style. display = "";
// No repeated request submitted after Initialization
If (! List. children. length ){
Ajax. request (editor. options. imageManagerUrl ,{
Timeout: 100000,
Action: "get ",
Onsuccess: function (xhr ){
// Remove Spaces
Var tmp = utils. trim (xhr. responseText ),
ImageUrls =! Tmp? []: Tmp. split ("ue_separate_ue "),
Length = imageUrls. length;
G ("imageList"). innerHTML =! Length? "& Nbsp;" + lang. noUploadImage: "";
For (var k = 0, ci; ci = imageUrls [k ++];) {
Var img = document. createElement ("img ");
Var div = document. createElement ("div ");
Div. appendChild (img );
Div. style. display = "none ";
G ("imageList"). appendChild (div );
Img. onclick = function (){
ChangeSelected (this );
};
Img. onload = function (){
This. parentNode. style. display = "";
Var w = this. width, h = this. height;
Scale (this, 100,120, 80 );
This. title = lang. toggleSelect + w + "X" + h;
};
Img. setAttribute (k <35? "Src": "lazy_src", editor. options. imageManagerPath + ci. replace (/s + | s +/ig ,""));
Img. setAttribute ("data_ue_src", editor. options. imageManagerPath + ci. replace (/s + | s +/ig ,""));
}
},
Onerror: function (){
G ("imageList"). innerHTML = lang. imageLoadError;
}
});
}
}

Delete it!

The above is Javascript. We have attached an article. NET added the image deletion function for the Baidu text editor UEditor..

1. First, modify imageManager. ashx in the ueditornet file on the server side to delete images. The Add section of the following code is shown:

The Code is as follows: Copy code

<% @ WebHandler Language = "C #" Class = "imageManager" %>
/**
* Created by visual studio2010
* User: xuheng
* Date: 12-3-7
* Time: PM
* To change this template use File | Settings | File Templates.
*/
Using System;
Using System. Web;
Using System. IO;
Using System. Text. RegularExpressions;

Public class imageManager: IHttpHandler
{

Public void ProcessRequest (HttpContext context)
{
Context. Response. ContentType = "text/plain ";


String [] paths = {"upload", "upload1"}; // list of directories to be traversed. It is best to use the thumbnail address. Otherwise, serious latency may occur when the network speed is slow.
String [] filetype = {". gif", ". png", ". jpg", ". jpeg", ". bmp"}; // file format allowed

String action = context. Server. HtmlEncode (context. Request ["action"]);

If (action = "get ")
{
String str = String. Empty;

Foreach (string path in paths)
{
DirectoryInfo info = new DirectoryInfo (context. Server. MapPath (path ));

// Directory Verification
If (info. Exists)
{
DirectoryInfo [] infoArr = info. GetDirectories ();
Foreach (DirectoryInfo tmpInfo in infoArr)
{
Foreach (FileInfo fi in tmpInfo. GetFiles ())
{
If (Array. IndexOf (filetype, fi. Extension )! =-1)
{
Str + = path + "/" + tmpInfo. Name + "/" + fi. Name + "ue_separate_ue ";
}
}
}
}
}

Context. Response. Write (str );
}

// Add Start ============================================ ==================================== 2013-05-12
// Delete the selected file
String pathDel = string. Empty; // it is best to use a thumbnail address. Otherwise, serious latency may occur when the network speed is slow.
String fileName = context. Server. HtmlEncode (context. Request ["fileName"]);
Bool isDeleted = false;
If (action = "del ")
{
Try
{

String fullPath = String. Empty;
Foreach (string path in paths)
{
PathDel = context. Server. MapPath (path );
DirectoryInfo info = new DirectoryInfo (pathDel );

// Directory Verification
If (info. Exists)
{
// Obtain the directory named after time under the directory C:... ueditornetupload. For example, 2013-05-12
DirectoryInfo [] infoArr = info. GetDirectories ();
Foreach (DirectoryInfo tmpInfo in infoArr)
{
Foreach (FileInfo fi in tmpInfo. GetFiles ())
{
// Determine whether the image type is specified, because the persistent attachment and image are in the same directory
If (Array. IndexOf (filetype, fi. Extension )! =-1)
{
If (fi. Name. Equals (fileName ))
{
FullPath = pathDel + "/" + tmpInfo. Name + "/" + fileName;
File. Delete (fullPath );
IsDeleted = true;
Break;
}
}
}
// Deleted and exclusive
If (isDeleted = true)
Break;
}
}
// Deleted and exclusive
If (isDeleted = true)
Break;
}
IsDeleted = false;
Context. Response. Write ("success ");
}
Catch
{
Context. Response. Write ("error ");
}
}
// Add End ============================================ ====================================== 2013-05-12
}

Public bool IsReusable
{
Get
{
Return false;
}
}
}

1 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.