this
is a special variable - each time a function is entered it takes on a new value.
In this case to make the outer function's this
available in the inner function, you can bind a new variable to it outside of the nested function:
$('#mainwrap img').click(function() {
var $this = $(this); // new variable here
mcImageManager.browse({
oninsert : function(o) {
src= o.focusedFile.url;
$this.attr("src", src ); // referenced here
}
});
});