Create a SharePoint function in which you define a Custom action . This feature can be installed on a SharePoint farm. Exploring user actions with Google, you will find many guides and examples.
In your case, you should use RegistrationType to define user interaction in order to associate the action with a specific type of content. (TopTip: use content types to manage your data, not file types).
source share