1

I've had a question from a client to enable image based stickers in the comment system. I've built a basic jQuery script which will allow the selection of a sticker and add it as markup in the comment textarea;

jQuery(".stickers img").click(function(){
   var img = jQuery(this).parent().html();
   var text = jQuery("#respond textarea").val();
   jQuery("#respond textarea").val(text + img);
});

While this works just fine upon hitting submit, the user is presented with raw HTML code until this happens.

I did see a plugin called "Rich Text Editor for Comments", but this appears to have been removed for the WP repository.

Does anyone know of a similar plugin, or how the comment textarea could be adapted to use rich text by default?

  • May be this will help wordpress.stackexchange.com/questions/22415/… – jas Aug 23 '16 at 7:56
  • Sorry for the delay, I have tried this solution already. For some reason the script does not enqueue, so I tried using CDN, but when initialising, I get a not defined error on tineMCE - the order is correct. – user1235285 Aug 30 '16 at 6:49
0

I have found a way by using nicEdit here's the tutorial.

In order to get this fully functioning, I had to amend my script slightly.

jQuery(".stickers img").click(function(){
    var img = jQuery(this).parent().html();
    var text = jQuery("#respond .nicEdit-main").html();
    jQuery("#respond .nicEdit-main").html(text + img);
});

I hope this helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.