Suppose I uploaded a media file for eg image, and its name is example_123_56737_303030.png
but before upload I want this name of the image to be changed as any thing of my choice (best will be post_id of this attachment) so it looks like 122.png (122 is the post_id of this attachment).
Now the things that needs to be achieved is :
- Name should be changed when I upload the file from back-end/front-end/directly in media/In post/In page/Any custom post type (means if media is uploaded from anywhere in the wordpress website).
- The serialize data which wordpress saves for every image, that are
_wp_attached_file
,_wp_attachment_metadata
inwp_post_meta
table should be as per the new name. - The image should be of the new name in the folder as well (upload place/directory is fine no changes required in that).