简体   繁体   中英

How to automatically set title to be the same as alt for img tag when using ckeditor with image2 plugin?

I want to be able to set the title tag to the final image in ckeditor using image2 plugin. When I use the image2 plugin the title tag disapears.

I have a fully operational ckeditor on my page, but would like to have a title tag that is automatically set when image is inserted to the alt given in the image2 dialog. I searched for hours for a solution but noone seems to have the same problem, so i decided to ask if anyone knows a solution for it.

I have tried using the CKEDITOR.replace method to change it on instanceReady:

CKEDITOR.replace('element_id',{
  on: {
       instanceReady: function() {
            this.dataProcessor.htmlFilter.addRules( {
                elements: {
                    img: function( el ) {
                       el.attributes.title = el.attributes.alt;
                    }
                }
            });            
        }
    }
});

but that didn't work..

tried this answer https://stackoverflow.com/a/34330124

that didn't work either

I have config.extraAllowedContent set to '*(*);*{*}' in config.js for ckeditor that should allow all tags and attributes.

按照https://stackoverflow.com/a/34330124进行操作 ,也许您必须在image2 plugin.js中进行更多调整,但是之后必须为浏览器清除cahce,因为它永远不会更新。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM