I'm trying to add the necessary html to the CkEditor editor, but nothing happens:

var html = '<a rel="group" class="fancybox" href="'+large_url+'">'+ '<i style="background-image: url('+small_url+')" class="uiMediaThumbImg"></i>'+ '</a>'; CKEDITOR.instances.message_text.insertHtml(html, "unfiltered_html"); 

Although if in html there is, for example, <p>Какой-то html</p> , then everything will be displayed correctly in the editor. Apparently, pouring on the piece, where there is a tag <i> .

Tell me, what's the problem?

  • You can search in the editor settings, the allowed tags are indicated, maybe you just need to allow the necessary tag ... - Boris Run

2 answers 2

Found a solution. Everything turned out to be simple: The <i> tag was to blame for everything <i> replaced it with <img> and it all worked. Here is the working code:

 var html = '<a rel="group" class="fancybox" href="'+large_url+'">'+ '<img src="'+small_url+'" class="uiMediaThumbImg">'+ '</a>'; CKEDITOR.instances.message_text.insertHtml(html, "unfiltered_html"); 
  • If you have found a solution, please mark the answer as a solution (the green daw below the digit to the left of the answer). - Alex

And somehow I did not try?

 var html = '<a rel="group" style="display: block; background-image: url('+small_url+')" class="fancybox uiMediaThumbImg" href="'+large_url+'">'+ '</a>'; 

Just a guess for reducing the number of lines.