Title: HTTPS for Post Thumbnails
Last modified: August 21, 2016

---

# HTTPS for Post Thumbnails

 *  [Jan Thiel](https://wordpress.org/support/users/janpeters/)
 * (@janpeters)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/)
 * Hi guys,
 * don’t know how to raise awarness anywhere else, so I try it here.
    Since WordPress
   2.9 there is no way to have a clean HTTPS page, because all Thumbnails are only
   loaded via HTTP.
 * That leads to possible security problems as well as a yellow SSL icon in the 
   browser bar.
 * The bug is filed for some time now. I keep the patch updated there regularily.
   But still it is not getting into core …
 * [https://core.trac.wordpress.org/ticket/20534](https://core.trac.wordpress.org/ticket/20534)
 * Any advices how to raise attention for this?
 * Thanks an brgds
 * Jan

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [kjohnson_2](https://wordpress.org/support/users/kjohnson_2/)
 * (@kjohnson_2)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593527)
 * My sincerest thanks for your effort!
 * I don’t have any helpful advice, though.
 * (That’s not completely true. My long-term plan is to switch platforms, that is,
   away from WordPress, but in the short term your patches help solve my immediate
   problems. I can’t say if my long-term plan would help you.)
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [12 years, 3 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593547)
 * > Since WordPress 2.9 there is no way to have a clean HTTPS page, because all
   > Thumbnails are only loaded via HTTP.
 * The plugin WordPress HTTPS corrects this.
 * [https://wordpress.org/plugins/wordpress-https/](https://wordpress.org/plugins/wordpress-https/)
 *  [chaoix](https://wordpress.org/support/users/chaoix/)
 * (@chaoix)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593704)
 * I wrote a filter for my hunctions.php in the meantime to resolve this issue. 
   Please note this issue only affects partial https sites. If your base_url and
   home_url are set to a https domain name, the post thumbnail urls will work correctly.
 * Something like below should definitely be in core.
 *     ```
       //Fix SSL on Post Thumbnail URLs
       	function ssl_post_thumbnail_urls($url, $post_id) {
       		//Skip file attachments
       		if( !wp_attachment_is_image($post_id) )
       			return $url;
   
       		//Correct protocol for https connections
       		list($protocol, $uri) = preg_split('@(://)@', $url, 2);
       		if( is_ssl() ) {
       			if( 'http' == $protocol )
       				$protocol = 'https';
       		} else {
       			if( 'https' == $protocol )
       				$protocol = 'http';
       		}
   
       		return $protocol.'://'.$uri;
       	}
       	add_filter('wp_get_attachment_url', 'ssl_post_thumbnail_urls', 10, 2);
       ```
   
 *  [chaoix](https://wordpress.org/support/users/chaoix/)
 * (@chaoix)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593715)
 * Amended the code above to remove the use of regex. It was adding significant 
   CPU load to pages with decent amounts of images.
 *     ```
       //Fix SSL on Post Thumbnail URLs
       	function ssl_post_thumbnail_urls($url, $post_id) {
       		//Skip file attachments
       		if( !wp_attachment_is_image($post_id) )
       			return $url;
   
       		//Correct protocol for https connections
       		list($protocol, $uri) = explode('://', $url, 2);
       		if( is_ssl() ) {
       			if( 'http' == $protocol )
       				$protocol = 'https';
       		} else {
       			if( 'https' == $protocol )
       				$protocol = 'http';
       		}
   
       		return $protocol.'://'.$uri;
       	}
       	add_filter('wp_get_attachment_url', 'ssl_post_thumbnail_urls', 10, 2);
       ```
   
 *  Thread Starter [Jan Thiel](https://wordpress.org/support/users/janpeters/)
 * (@janpeters)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593716)
 * Hi guys, just got great news form WordCamp Germany. In one of the sessions I 
   mentioned the HTTPS problem in general and got into discussion with an Automattic
   guy. He told me that there will be (full?) Core HTTPS support in one of the next
   WP versions… finally 🙂
 * So lets keep our fingers crossed and hacks out of our code 😉
 * Greetings from Germany,
 * Jan
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593717)
 * For more information I believe you can read about it here.
 * > [SSL taskforce](https://make.wordpress.org/core/2014/06/11/ssl-taskforce/)
 * Make/core is a good blog to subscribe to. 😉
 *  Thread Starter [Jan Thiel](https://wordpress.org/support/users/janpeters/)
 * (@janpeters)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593718)
 * Thx Jan. Yes, you are absolutely correct about subscribing it! So good to see
   the word is already out 🙂
 *  [ajmancilla](https://wordpress.org/support/users/ajmancilla/)
 * (@ajmancilla)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593719)
 * hey Matthew just wanted to thank you for the snippet. fixed my problem right 
   away. thanks!
 *  [chaoix](https://wordpress.org/support/users/chaoix/)
 * (@chaoix)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593720)
 * [@ajmancilla](https://wordpress.org/support/users/ajmancilla/) Glad to hear I
   am not the only one with this issue :D.
    [@jan](https://wordpress.org/support/users/jan/)
   Dembowski Thanks for the information on the SSL taskforce. Thats an interesting
   read.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘HTTPS for Post Thumbnails’ is closed to new replies.

## Tags

 * [HTTP](https://wordpress.org/support/topic-tag/http/)
 * [HTTPS](https://wordpress.org/support/topic-tag/https/)
 * [thumbnails](https://wordpress.org/support/topic-tag/thumbnails/)
 * [trac](https://wordpress.org/support/topic-tag/trac/)

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 9 replies
 * 6 participants
 * Last reply from: [chaoix](https://wordpress.org/support/users/chaoix/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/https-for-post-thumbnails/#post-4593720)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
