You can use AWS S3 bucket to store all media files ( images, static files i.e css,js etc ). Whatever you upload ( product images, wysiwyg images ) from magento admin it will be uploaded on S3 bucket.
To achieve this you have to use and configure Thai's S3 Storage extension ( https://github.com/thaiphan/magento-s3 ).
After installation and configuring extension correctly, you will find a new option "Amazon S3" in "Storage Configuration for Media" under :
Stores > System > Configurations > Advanced > System
Select "Amazon S3" , save settings and flush cache.
Once everything is setup you are good to go now. You don't need to do any changes in templates, your all product, category and wysiwyg images will be stored on S3 and will be rendered on front-end from bucket.