You should consider that the function dismissRelatedImageLookupPopup is defined in static/filer/js/popup_handling.js and is used for all types of files. Maybe it's better to use 2 different methods: one for regular files and one for image files. Also, the code for both should be found in filer, not in cmsplugin image, since filer should work by itself, without the cmsplugin image.