Randomly Assign an Image’s Alt Text Based on Data From Post
Just set the image alt text when the image is saved. Hook onto the save_post action, check if any of the attached images don’t have alt text, and if not then generate the alt text you want and save it with: update_post_meta( $attachment_id, ‘_wp_attachment_image_alt’, ‘this is the alt text’ );