TinyMCE + IMCE
เจอปัญหาเวลาจะใช้ module IMCE ร่วมกับ TinyMCE
เพราะมันทำงานแยกกัน ไม่สามารถเอา IMCE มาใช้ใน Images Toold ของ TinyMCE
เคยแก้ไปทีนึงแล้ว ก็ลืม คราวนี้เลย blog ทิ้งไว้หน่อย
- ลง TinyMCE และ IMCE ตามปกติ
- เช็ค Profile กับ Permission ของทั้ง 2 module ให้เรียบร้อย
- add code ด้านล่างลงในไฟล์ template.php ที่อยู่ใน theme (ถ้า theme ที่ใช้ไม่มีก็สร้างไฟล์ใหม่ได้เลย)
<?php function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) { } $init = theme_tinymce_theme($init, $textarea_name, $theme_name, $is_running); if ($init && $access) { $init['file_browser_callback'] = 'imceImageBrowser'; $integrated = TRUE; drupal_add_js(" function imceImageBrowser(field_name, url, type, win) { tinyOpenerWin = win, tinyTargetField = field_name; if (typeof tinyImceWin == 'undefined' || tinyImceWin.closed) { tinyImceWin = window.open(Drupal.settings.basePath +'?q=imce', '', 'width=760,height=560,resizable=1'); tinyImceWin['imceOnLoad'] = function () { tinyImceWin.imce.highlight(url.substr(url.lastIndexOf('/')+1)); tinyImceWin.imce.setSendTo(Drupal.t('Send to @app', {'@app': 'TinyMCE'}), function(file) { window.focus(); tinyOpenerWin.focus(); $('#width', tinyOpenerWin.document).val(file.width); $('#height', tinyOpenerWin.document).val(file.height); $('#'+ tinyTargetField, tinyOpenerWin.document).val(file.url).focus(); }); } } else { tinyImceWin.imce.highlight(url.substr(url.lastIndexOf('/')+1)); } tinyImceWin.focus(); } ", 'inline'); } } return $init; } ?>
- clear cached date ที่ admin/settings/performance
- เป็นอันเสร็จ








