hook add_attachment cannot complete its work

Good afternoon!

I need to clear everything fields when inserting an image in the WordPress loader.

On the Internet, I found a function:

It clears the fields but does not show the image (see the image):

image

How can this be fixed?

Thanks!