mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Force default og:image to https
If we can't figure out a good image to hint as a thumbnail for a page via `og:image`, we set it to the reddit snoo icon. However, we have been making this a protocol-relative url. This doesn't appear to be against [the spec][0], but it does create problems for some scrapers. Now we force it to be an https url, which should resolve some of those issues. [0]: http://opengraphprotocol.org/#url
This commit is contained in:
@@ -1511,7 +1511,10 @@ class LinkInfoPage(Reddit):
|
||||
# thumbnails.
|
||||
return self.link.thumbnail
|
||||
|
||||
return static('icon.png')
|
||||
# Default to the reddit icon if we've got nothing else. Force it to be
|
||||
# absolute because not all scrapers handle relative protocols or paths
|
||||
# well.
|
||||
return static('icon.png', absolute=True)
|
||||
|
||||
def _build_og_description(self, meta_description):
|
||||
if self.link.selftext:
|
||||
|
||||
@@ -65,6 +65,10 @@ def static(path, absolute=False, mangle_name=True):
|
||||
path_components = []
|
||||
actual_filename = None if mangle_name else filename
|
||||
|
||||
# If building an absolute url, default to https because we like it and the
|
||||
# static server should support it.
|
||||
scheme = 'https' if absolute else None
|
||||
|
||||
if g.static_domain:
|
||||
domain = g.static_domain
|
||||
else:
|
||||
@@ -93,7 +97,7 @@ def static(path, absolute=False, mangle_name=True):
|
||||
query = 'v=' + str(file_id)
|
||||
|
||||
return urlparse.urlunsplit((
|
||||
None,
|
||||
scheme,
|
||||
domain,
|
||||
actual_path,
|
||||
query,
|
||||
|
||||
Reference in New Issue
Block a user