How to link images with topic

There is a plugin API function register_upload_in_use

For an example on how to use it, see the code in the Chat plugin.