I am trying to write a function to upload and delete images on frontend with dropzonejs uploader, and so far i managed to make everything work.
But the problem is that i need to secure it that the image that is deleting is actually uploaded by the user who is deleting image.
In wordpress admin area in media library when i click on image, in attachments details there is a
Uploaded by with username who uploaded specific image.
But on searching all over the net and wordpress codex i didn't find any info how to retrieve user id who uploaded the image.
So id i have image id and try to delete with
wp_delete_attachment is there a way to check who is the uploader of that image and compare logged in user id with image uploader id and if those two match delete the image.