TinyMCE Add class to image

Asked by: chris11
Date:
Viewed: 242
Answers: 1
  • 0

Is it possible to add an extra class to an image added via the insert image tab of the TinyMCE editor? If yes, can anyone explain how? Thanks

Answers

Answer by: ChristianKovats

Answered on: 20 Jul 2023

  • 0

If you use the Bootstrap framework, you might want to add the responsive class “img-fluid” (or create your own responsive image class) to each image you use on your website. By default TinyMCE won’t use this class, so you need to add some extra code to your TinyMCE init function. Under the toolbar, add the following array:

image_class_list: [
   {title: 'None', value: ''},
   {title: 'Responsive', value: 'img-fluid'}
],

As you can see first, you name your class, then you add the actual value/name of the class.

If you did everything right, you should see something like this:

tinymce

 

Please log in to post an answer!