image.uploaded

Arguments
image Objectobject of uploaded image
response ObjectJSON object with data from upload script

Triggered on successful image upload (including via drag and drop).

$R('#content', {
        imageUpload: '/myadmin/images/upload/',
    callbacks: {
        image: {
            uploaded: function(image, response)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            uploaded: function(image, response)
            {
                // ...
            }
        }
    });
})(Redactor);

Upload script forms a JSON string:

{
    "url": "/images/myimage.jpg",
    "id": 1
}

JSON may contain any data, however, url are required.

image.uploadError

Arguments
response ObjectJSON object with error data

Triggered whenever there is an error in image upload. JSON example:

{
    "error": true,
    "message": "Something went wrong..."
}

Callback example:

$R('#content', {
        imageUpload: '/myadmin/images/upload/',
    callbacks: {
        image: {
            uploadError: function(response)
            {
                alert(response.message);
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            uploadError: function(response)
            {
                // ...
            }
        }
    });
})(Redactor);

image.delete

Arguments
image Objectobject of the image to be deleted

Triggered before the image will be deleted. This callback allows you to prevent image deletion if you return false.

$R('#content', {
    callbacks: {
        image: {
        delete: function(image)
            {
                 if (some_condition)
                 {
                        // success
                        return true;
                  }
                  else
                   {
                      // fail
                     return false;
                    }
            }
      }
      }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            delete: function(image)
            {
                 if (some_condition)
                 {
                        // success
                        return true;
                  }
                  else
                   {
                      // fail
                     return false;
                    }
            }
        }
    });
})(Redactor);

image.deleted

Arguments
image Objectobject of deleted image

Triggered when the image is deleted.

$R('#content', {
        imageUpload: '/myadmin/images/upload/',
    callbacks: {
        image: {
            deleted: function(image)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            deleted: function(image)
            {
                // ...
            }
        }
    });
})(Redactor);

image.resize

Arguments
image Objectobject of resizable image

Triggered before the image resize is started.

$R('#content', {
    callbacks: {
        image: {
            resize: function(image)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            resize: function(image)
            {
                // ...
            }
        }
    });
})(Redactor);

image.resized

Arguments
image Objectobject of resized image

Triggered when the image is resized.

$R('#content', {
    callbacks: {
        image: {
            resized: function(image)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            resized: function(image)
            {
                // ...
            }
        }
    });
})(Redactor);

image.changed

Arguments
image Objectobject of changed image

Triggered when the image is changed. If the new image replaces the old one or if the image was edited.

$R('#content', {
    callbacks: {
        image: {
            changed: function(image)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            changed: function(image)
            {
                // ...
            }
        }
    });
})(Redactor);

image.inserted

Arguments
image Object image object

Triggered when the image is inserted to Redactor with Insertion service API.

$R('#content', {
    callbacks: {
        image: {
            inserted: function(image)
            {
                // ...
            }
        }
    }
});

Listen to the message in a plugin:

(function($R)
{
    $R.add('plugin', 'myplugin', {
        init: function(app)
        {
            // define app
            this.app = app;
        },

        // messages
        onimage: {
            inserted: function(image)
            {
                // ...
            }
        }
    });
})(Redactor);