Wordpress에서 이미지 업로드시 오류 - 2Oct 10, 2006
이전 포스트에서 썼던 것처럼 IE에서 Wordpress 의 inline upload 기능을 사용해서 이미지를 업로드하고 첨부할 경우 크기가 강제로 지정이 되어버리고, link to page/image 기능을 이용할 경우 <a> 태그가 종료되지 않는다거나, rel 속성에 quotation 이 되지 않는 버그가 있다.
다시 수정한 버전. <a> 태그도 제대로 닫아주고 rel 속성에서도 제대로 따옴표를 붙여준다.
wp-admin/inline-uploading.php 를 열어 429라인의 sendToEditor 함수를 다음과 같이 고치면 됨. 사실 자세히 보면 알겠지만 손톱만큼 정규식 고치고 순서 바꿔준거밖에 없다.
JAVASCRIPT:
-
function sendToEditor(n) {
-
o = document.getElementById('div'+n);
-
h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
-
h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
-
h = h.replace(new RegExp(' (width|height)="{0,1}[0-9]{1,}"{0,1}', 'g'), ''); // Drop size constraints
-
h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
-
h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
-
h = h.replace(new RegExp(' (class|alt|title|rel|id)=([^"> ]*)', 'g'), ' $1="$2"'); // Enclose attribs in quotes
-
h = h.replace(new RegExp('"""', 'g'), '"'); // Fix tripple quote
-
h = h.replace(new RegExp('(<img .+?")/>', 'g'), '$1 />'); // XHTML
-
if ( richedit )
-
win.tinyMCE.execCommand('mceInsertContent', false, h);
-
else
-
win.edInsertContent(win.edCanvas, h);
-
}
덧붙임.
블로그 옮기면서 사진과 일상생활의 기록 외에 컴퓨터에 관련된 이야기는 전혀 안쓰려고 했는데 좀처럼 잘 안되네..