4
votes

When Uploading a image through Redactor

Redactor will generate <img src="blablabla.png"/> tag

What if I want the tag is like:

<img class="myClass" src="blablabla.png"/>

How to do this?

I have viewed all the API and Callback but I didn't find any method to implement this.

1
It seems a quite specific requirement, can ppl assign classes to images through the editor? - Filype
@Filype ya quite specific. But I think it can easily for user to change the image tag template. - Huei Tan

1 Answers

3
votes

It looks like you can use the imageUploadCallback.

This callback is triggered on successful image upload and the image DOM element is there for you to manipulate.

$('#redactor').redactor({
    imageUploadCallback: function(image, json)
    {
        // image = this is DOM element of image
        // json = for example: { "filelink": "/images/img.jpg" }
    }
});