#17066·ckeditor5

custom class for images

Author: cnaughtCreated Sep 9, 2024Updated Sep 14, 2026
Labelstype:questionpackage:image

I'm having a hard time figuring out how to add an option to the toolbar that I can click to add a class to an image (class="img-fluid"). I'd be happy with either a predefined button in the "Styles" drop down, or even a button on the image toolbar (either to type or a pre-defined button. I have tried 100 different ways, and I can't seem to get any to work. Any help would be greatly appreciated. Thank you.

I tried adding this to the style definitions, but it appears under Blockquote, and it's greyed out when I click on the image. { name: 'Responsive Img', element: 'img', classes: ['img-fluid'] }

I also tried adding 'ImageStyle:class' or className, to the toolbar, but that didn't work either.

image: { toolbar: [ 'toggleImageCaption', 'imageTextAlternative', '|', 'imageStyle:inline', 'imageStyle:wrapText', 'imageStyle:breakText', 'imageStyle:class', '|', 'resizeImage' ] },