Amazon S3, SSL & Craft

Ian Ebden · September 18, 2015

Looks like this article was written a while ago. Some of the ideas and/or techniques described may now be obselete.

Hooking up Amazon's CloudFront service to your S3 account can fix this, but it's a costly solution. Another option is to configure SSL for your S3 bucket via CloudFlare. But here's a super-simple super-quick workaround that costs nothing.

{{ image.getUrl(yourTransformName)|replace({'http:':''}) }}

All I'm doing is using the Twig 'replace' filter to strip the protocol off the file url so the browser request ends up looking like:

<img src="//" alt=""/>

With no protocol specified the browser will just use the current one – http on local or https on production. Amazon already have SSL on their S3 domains so your image will load fine on either protocol.