The recommended solution is to generate multiple versions of the image at different sizes during build time or use a content delivery network (CDN) to serve the appropriate image size on the fly.