File tree 2 files changed +7
-3
lines changed
tests/roots/test-image-rel-paths 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def get_tags(
119
119
120
120
fields .pop ("og:image:alt" , None )
121
121
122
+ first_image = None
122
123
if ogp_use_first_image :
123
124
first_image = doctree .next_node (nodes .image )
124
125
if (
@@ -127,19 +128,21 @@ def get_tags(
127
128
):
128
129
image_url = first_image ["uri" ]
129
130
ogp_image_alt = first_image .get ("alt" , None )
131
+ else :
132
+ first_image = None
130
133
131
134
if image_url :
132
135
# temporarily disable relative image paths with field lists
133
136
if "og:image" not in fields :
134
137
image_url_parsed = urlparse (image_url )
135
138
if not image_url_parsed .scheme :
136
139
# Relative image path detected, relative to the source. Make absolute.
137
- if config ["ogp_image" ]:
140
+ if first_image :
141
+ root = page_url
142
+ else : # ogp_image is set
138
143
# ogp_image is defined as being relative to the site root.
139
144
# This workaround is to keep that functionality from breaking.
140
145
root = config ["ogp_site_url" ]
141
- else :
142
- root = page_url
143
146
144
147
image_url = urljoin (root , image_url_parsed .path )
145
148
tags ["og:image" ] = image_url
Original file line number Diff line number Diff line change 7
7
8
8
ogp_site_name = "Example's Docs!"
9
9
ogp_site_url = "http://example.org/en/latest/"
10
+ ogp_image = "_static/image33.png"
10
11
ogp_use_first_image = True
You can’t perform that action at this time.
0 commit comments