Opened 9 years ago
Last modified 5 years ago
#35648 new defect (bug)
the_post_thumbnail sets srcset with http protocol
Reported by: | javiertoledos | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4 |
Component: | Media | Keywords: | reporter-feedback https bulk-reopened |
Focuses: | Cc: |
Description
We have a wordpress site that uses https always, when we use the_post_thumbnail, it returns HTTPS for the SRC attribute but it returns HTTP values for the SRCSET attribute. This is not a duplicate of #28261 or #15928 because this only happens on the srcset attribute.
We had to do this filter in order to do a quick patch:
<?php function fix_srcset_https_thumb_images ($html) { if ( is_ssl()) { $html = str_replace('http://','https://',$html); } return $html; } add_filter('post_thumbnail_html','fix_srcset_https_thumb_images') ;
Attachments (1)
Change History (8)
#1
@
9 years ago
@javiertoledos Can you please let us know how you've forced the site to HTTPS only?
Are you using any SSL constants? Plugins? What's your WordPress URL / Site URL set to (Settings -> General)? Is the media URL set to anything under Settings -> Media?
#2
@
9 years ago
- Component changed from Post Thumbnails to Media
- Focuses ui javascript administration removed
- Version changed from 4.4.1 to 4.4
#6
@
9 years ago
Following the code trail: For src, comes from wp_get_attachment_image_src
<- image_downsize
<- wp_get_attachment_url
where the url is fixed using set_url_scheme
. This doesn't happen for srcset, which pulls its base url straight from _wp_upload_dir_baseurl
.
Presumably, this could be fixed just after this point (search for $image_baseurl
in wp_calculate_image_srcset
), in a similar manner. Might be worth investigating putting it lower down in the root wp_upload_dir
, though?
Screenshot of the SRC HTTP bug