Updating Media Published Date When Parent Post Is Modified in WordPress

I am hoping to make the published date of my media files always equal the modified date of the post it’s attached to.


Image 1 (date: 1/1/20 5:00PM) is attached to Post 1 (date: 1/1/20 5:00PM)

Post 1 is updated on 1/2/20 5:00PM > Image 1 updates it’s published time in the db to 1/2/20 5:00PM

So far I have this function, and it works for the parent post to make the published time = modified time, but I need it to work on the child post (the image in post_meta db) rather than the parent.

So, how can I make this code above work for updating the published date of the image child post in post_meta?