I'm looking for a way to regenerate all images in media library and set ALT and TITLE to those that missing.
Something like what this plugin do + what I mentioned.
All codes people prepared are for set it WHILE UPLOADING image, not for images are already in media library, like this one:
https://brutalbusiness.com/automatically-set-the-wordpress-image-title-alt-text-other-meta/
changing titles/alt-text for previously uploaded images is a COMPLETELY different problem than what the code in this post aims to solve, because of the way WordPress handles images that are inserted into posts/pages.
The key point regarding previously uploaded images is that when you insert those images into a post/page, the image title and alt-text are COPIED into the html of the post/page by WordPress. So if you subsequently change the title/alt-text of the image in the media library, it will NOT affect any post/pages where that image is displayed, since the title/alt-text of the image was copied over into the post/page (and therefore will NOT be refreshed with the new image/alt-text from the media library).
Any updated image title/alt-text in the media library will only appear on posts/pages when the image is inserted into the post/page AFTER the title/alt-text was updated in the media library.
any idea will help.