The php version adds the image deletion function to the online image governance section of UEditor.

Source: Internet
Author: User
The php version adds the image deletion function to the online image management section of UEditor. 1. locate uediordialogsimageimage. js file, Add as part of the modified code: ** tab click to process events * @ paramtabHeads * @ paramtabBodys * @ paramobj * functionclickHandler (tabHeads, tab php adds the image deletion function to the online image management section of UEditor.

1. find the uedior/dialogs/image. js file and Add it to the modified code:

/*** Tab click to process events * @ param tabHeads * @ param tabBodys * @ param obj */function clickHandler (tabHeads, tabBodys, obj) {// head style change for (var k = 0, len = tabHeads. length; k <len; k ++) {tabHeads [k]. className = "";} obj. className = "focus"; // body explicit/hidden var tabSrc = obj. getAttribute ("tabSrc"); for (var j = 0, length = tabBodys. length; j <length; j ++) {var body = tabBodys [j], id = body. getAttribute ("id "); Body. onclick = function () {this. style. zoom = 1 ;}; if (id! = TabSrc) {body. style. zIndex = 1;} else {body. style. zIndex = 200; // when switching to a local image upload, hide the iframe if (id = "local") {toggleFlash (true); maskIframe. style. display = "none"; // process the status of the OK button if (selectedImageCount) {dialog. buttons [0]. setDisabled (true) ;}} else {toggleFlash (false); maskIframe. style. display = ""; dialog. buttons [0]. setDisabled (false);} var list = g ("imageList"); list. style. display = "none "; // When switching to image management, ajax requests the background image list if (id =" imgManager ") {list. style. display = ""; // 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? "" + Lang. noUploadImage: ""; for (var k = 0, ci; ci = imageUrls [k ++];) {// Add Start ================================== var p = document. createElement ("p"); var img = document. createElement ("img"); var del = document. createElement ("img"); var p = document. createElement ("p"); p. appendChild (img); p. appendChild (p); p. appendChild (del); p. style. display = "none"; img. style. height = "100px"; img. style. width = "100px"; del. setAttribute ("src", "images/del.png"); p. style. marginTop = "-pixel PX"; p. style. marginLeft = "90px"; g ("imageList "). appendChild (p); img. onclick = function () {changeSelected (this) ;}; del. onclick = function () {var me = this, src = me. getAttribute ("alt", 2); var pic = me. parentNode. parentNode. childNodes [0]; if (! Confirm ("The delete operation cannot be recovered. Are you sure you want to delete this image? ") Return; ajax. request (editor. options. imageManagerUrl, {action: "del", fileName: src. substr (src. lastIndexOf ("/") + 1), onsuccess: function (xhr) {me. parentNode. parentNode. removeChild (pic); me. parentNode. removeChild (me) ;}, onerror: function (xhr) {alert ("The server failed to delete the image. please try again! ");}});}; // Add End ==================================== 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; this. onload = null ;}; img. setAttribute (k <35? "Src": "lazy_src", editor. options. imageManagerPath + ci. replace (/\ s + | \ s +/ig, ""); img. setAttribute ("title", editor. options. imageManagerPath + ci. replace (/\ s + | \ s +/ig, ""); img. setAttribute ("width", "100px"); img. setAttribute ("height", "100px"); del. onload = function () {// set the style when the del image is loaded this. style = "border: 0"; this. onload = null ;}; del. setAttribute ("alt", editor. options. imageManagerPath + ci. replace (/\ s + | \ s +/ig, "") ;}}, onerror: function () {g ("imageList "). innerHTML = lang. imageLoadError ;}}) ;}} if (id = "imgSearch") {selectTxt (g ("imgSearchTxt");} if (id = "remote ") {$ focus (g ("url "));}}}}

Find the uedior/php/imageManager. php file and add the following content:

if ($action == "del") {    $fileName = $_POST['fileName'];    foreach($paths as $path) {        $str1 = delfiles($fileName, $path);        break;    }}function delfiles($fileName, $path, &$files = array()) {    if (!is_dir($path)) return null;    $handle = opendir($path);    while (false !== ($file = readdir($handle))) {        if ($file != '.' && $file != '..') {            $path2 = $path.'/'.$file;            if (is_dir($path2)) {                delfiles($fileName, $path2, $files);            } else {                if (preg_match("/\.(gif|jpeg|jpg|png|bmp)$/i", $file)) {                    $path3 = str_replace('../../', '/static/', $path2);                    $fileImg = basename($path3);                    if ($fileImg == $fileName) {                        $is_del = unlink($path2);                    }                }            }        }    }}





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.