IMCE : 挿入されるファイルのパスを変更する
IMCE モジュールを利用して画像の挿入やファイルへのリンクを作成した場合、デフォルトで挿入されるファイルのパスは、files/sub/xxx.jpg のようなファイルシステムからの相対パスとなっている。
通常は問題ないが、環境によってはファイルのパスを http://example.com/files/sub/xxx.jpg という絶対パスで挿入しなければ期待通りの動作にならない場合があるようなので、その方法。
imce_set_inline.js の //custom callback. hook:ImceFinish の部分に修正を加える。
強調部分が追加した内容。(追加部分は 2 箇所)
//custom callback. hook:ImceFinish
function _imce_ImceFinish(path, w, h, s, imceWin) {
var basename = path.substr(path.lastIndexOf('/')+1);
var type = imceActiveType=='link' ? 'link' : (w&&h ? 'image' : 'link');
var html = type=='image' ? ('<img src="'+'http://'+ location.host + path +'" width="'+ w +'" height="'+ h +'" alt="'+ basename +'" />') : ('<a href="'+'http://'+ location.host + path +'">'+ basename +' ('+ s +')</a>');
imceInsertAtCursor(imceActiveTextarea, html, type);
imceWin.close();
imceActiveType = null;
}
トラックバック
トラックバックは承認後に表示されます。
URLから "-nospam" を削除してトラックバックを送信してください。