Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use absolute paths for og:image #43

Closed
nabobalis opened this issue Jun 24, 2021 · 2 comments · Fixed by #48
Closed

Use absolute paths for og:image #43

nabobalis opened this issue Jun 24, 2021 · 2 comments · Fixed by #48
Labels
bug Something isn't working

Comments

@nabobalis
Copy link

(Not sure if this is the best place to ask this)

I wanted the first image to use the image in our example gallery that is powered by sphinx-gallery.
This is on RTD.

This extension works very well on the gallery pages but the issue is that due to the relative paths that the gallery produces, open graph can't resolve the image path in previews.

E.g.,

<meta property="og:image" content="../../../_images/sphx_glr_downloading_lascoC2_001.png" />

I asked the people at Sphinx-Gallery if it was possible to work around this got this response:

Sphinx Gallery generated rst gives an image directive with a relative path to the image, e.g., from our an example in our docs:

.. image:: /auto_examples/images/sphx_glr_plot_0_sin_001.png
    :alt: plot 0 sin
    :class: sphx-glr-single-img

when Sphinx generates the html, it looks like this:

<img alt="plot 0 sin" class="sphx-glr-single-img" src="../_images/sphx_glr_plot_0_sin_001.png" />

so it looks like sphinxext-opengraph is pulling the image info from the html page generated, does this seem right for your example? Is there a way to set the config for sphinxext-opengraph such that you can specify a pattern and do some string formatting to get the image url? For example the image above has the following url:

https://sphinx-gallery.github.io/stable/_images/sphx_glr_plot_0_sin_001.png

sphinx-gallery/sphinx-gallery#707 (comment)

Is it possible to work around this via configuration in sphinxext-opengraph?

@TheTripleV
Copy link
Member

Yes, I think so. sphinxext-opengraph should be able to resolve all paths to absolute paths.

@TheTripleV TheTripleV changed the title sphinx-gallery and first image for a relative path Use absolute paths for og:image Jun 24, 2021
@astrojuanlu
Copy link

Came here to report this same issue, I observed it while trying to adopt the extension on the Read the Docs blog: readthedocs/blog#118

The generated image link is wrong: background-image: url("https://readthedocs-blog--118.org.readthedocs.build../_images/rebuild.png");

astrojuanlu added a commit to readthedocs/blog that referenced this issue Jul 22, 2021
@Daltz333 Daltz333 added the bug Something isn't working label Jul 22, 2021
Robpol86 added a commit to Robpol86/sphinxext-opengraph that referenced this issue Nov 15, 2021
Always using absolute/full URLs for og:image as long as
`config["ogp_site_url"]` is set.

Fixes wpilibsuite#43
Robpol86 added a commit to Robpol86/sphinxext-opengraph that referenced this issue Nov 15, 2021
Always using absolute/full URLs for og:image as long as
`config["ogp_site_url"]` is set.

Fixes wpilibsuite#43
Daltz333 pushed a commit to Robpol86/sphinxext-opengraph that referenced this issue Nov 20, 2021
Always using absolute/full URLs for og:image as long as
`config["ogp_site_url"]` is set.

Fixes wpilibsuite#43
Daltz333 pushed a commit that referenced this issue Nov 20, 2021
Always using absolute/full URLs for og:image as long as
`config["ogp_site_url"]` is set.

Fixes #43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants