Quick tip: https and wp_get_attachment_url

Today I have been playing around with Varnish, SSL and SPDY in relation to WordPress hosting. Now, one thing that I noticed was that several images were using the http protocol instead of https – which seemed to be caused by wp_get_attachment_url.

Luckily we can use the WordPress filters to fix this issue pretty easily, as shown in the gist below. This will simply replace the http:// in the URL with https:// if SSL is being used.

Apparently this has been an issue for quite some time, but still hasn’t been fixed in WordPress.