I have a custom filebrowser module that iv created for the site im working on, it gets images from an archive or directly uploaded, switches to a cropview, and gets cropped and a fileurl gets returned (all ajax).
My question is, how can i add a button in the ckeditor toolbar, that once pressed, calls this image popup, goes through the steps and if all goes well and fileurl is returned, inserts the image where the cursor was in ckeditor when the module was called.
Edit: bascily what i want is to add a button to the toolbar that runs a javascript function outside of the ckeditor scope.

Looking for an image tool with a image dropdown list
I am looking for a dialog that shows pre-loaded images and allows selecting one, etc. Is this what you have produced?
The imagearchive i have
The imagearchive i have created is very spesific for the project im working on and not really realated to ckeditor at all, wouldnt be reusable sorry.
I have managed to get it working with ckeditor in the way that it does insert the image after cropping. My problem now is that i have created a widget that is supposed to hold the image, and i insert the html for that widget manually but it does not initialize (untill i save and realod the content).
Is there a way to trigger the ckeditor to refresh its content and initialize any non-initialized widgets ?