Set File as public by default on specific attach field

i Would like to set the file’s is private field to 0 by default after attaching a doc to a specific doc. It would be great if we could change this in the attach field level. I tried to do this automaticaly by changing is_private field to 0 before File save when the attached_to_doctype field is in a predefined list but it seems that sometimes (i don’t know why) attaching a file to document does not fill the attached_to_doctype field