File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
tests/roots/test-image-rel-paths Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -119,6 +119,7 @@ def get_tags(
119119
120120 fields .pop ("og:image:alt" , None )
121121
122+ first_image = None
122123 if ogp_use_first_image :
123124 first_image = doctree .next_node (nodes .image )
124125 if (
@@ -127,19 +128,21 @@ def get_tags(
127128 ):
128129 image_url = first_image ["uri" ]
129130 ogp_image_alt = first_image .get ("alt" , None )
131+ else :
132+ first_image = None
130133
131134 if image_url :
132135 # temporarily disable relative image paths with field lists
133136 if "og:image" not in fields :
134137 image_url_parsed = urlparse (image_url )
135138 if not image_url_parsed .scheme :
136139 # 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
138143 # ogp_image is defined as being relative to the site root.
139144 # This workaround is to keep that functionality from breaking.
140145 root = config ["ogp_site_url" ]
141- else :
142- root = page_url
143146
144147 image_url = urljoin (root , image_url_parsed .path )
145148 tags ["og:image" ] = image_url
Original file line number Diff line number Diff line change 77
88ogp_site_name = "Example's Docs!"
99ogp_site_url = "http://example.org/en/latest/"
10+ ogp_image = "_static/image33.png"
1011ogp_use_first_image = True
You can’t perform that action at this time.
0 commit comments