名前をidと同じに設定できないため、name属性の代わりにidを選択するように以下のjQueryを調整しようとしています。また、タイトル属性を選択させてみました。私はjQueryを初めて使用し、完全に理解していません。完全に間違っていますか、それとも機能するために何をする必要がありますか?
jQuery(document).ready(function () {
var formfield;
jQuery('.upload_image_button').click(function () {
jQuery('html').addClass('Image');
formfield = jQuery(this).prev().attr('name');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});
window.original_send_to_editor = window.send_to_editor;
window.send_to_editor = function (html) {
if (formfield) {
fileurl = jQuery('img', html).attr('src');
jQuery('#' + formfield).val(fileurl);
tb_remove();
jQuery('html').removeClass('Image');
} else {
window.original_send_to_editor(html);
}
};
});