CKEditor 이미지 클래스 고정하기

2020. 7. 1. 20:16개발자료/Web


반응형

CKEditor 을 사용하는 페이지에 아래 자바스크립트 코드 추가

CKEDITOR.on('instanceReady', function (ev) {
	ev.editor.dataProcessor.htmlFilter.addRules({
		elements:{
			$: function (element) {
				// check for the tag name
				if (element.name == 'img') {
					element.attributes.class = "img-fluid" // Put your class name here
				}
				// return element with class attribute
				return element;
			}
		}
	});
});

 

참고

https://stackoverflow.com/questions/58863803/set-default-stylesheet-class-for-images-uploaded-using-django-ckeditor

 

Set Default Stylesheet Class for Images Uploaded using Django-CKEditor

I am using CK-Editor and Django (via django-ckeditor) to create a rich text field and upload images. However, some images are pretty large and I'd normally use bootstrap to make them responsive wit...

stackoverflow.com

 

반응형