我希望任何人都可以帮助我

使用wordpress过滤器,我修改了将发送给编辑器的图像标签 . 我使用的数据属性包含不同设备的图像网址 . js脚本从data-attribute设置image-src . 作为后备,我在每个img-tag之后使用noscript-tag .

所以现在我必须在wordpress编辑器中删除图像时删除noscript-tag .

我的tiny_mce_before_init过滤器的init-Array看起来像这样:

$initArray['setup'] = <<<JS
[function(ed) {
              ed.on('KeyDown', function (e) {
                var editor = tinyMCE.activeEditor;
                if ((e.keyCode == 8 || e.keyCode == 46) && editor.selection) {

                    var selectedNode = editor.selection.getNode();
                    console.log(selectedNode);
                    if (selectedNode && selectedNode.nodeName == 'IMG') {

                        delete_img_noscript(selectedNode.src); // A callback that will let me invoke the deletion of the image on the server if appropriate for the image source.
                        alert(selectedNode);
                        //selectedNode.next('noscript').remove();
                    }
                }
            });

}][0]
JS;