I have an add media field , by which I upload/select imagefrom media library.
Now I want to generate the thumbnail of the images to display
WP automatically generates several size images when you upload. You can add to these sizes. It is up to your theme to use the different sizes.
https://www.hostinger.com/tutorials/wordpress-images-sizes
https://premium.wpmudev.org/blog/wordpress-image-sizes/