Fix tile images linking to themselves instead of their pages - #1513
Fix tile images linking to themselves instead of their pages#1513deepusnath wants to merge 2 commits into
Conversation
Sphinx's html_scaled_image_link defaults to True, which auto-wraps any image using :height:, :width:, or :scale: in a link to its own unscaled file. The homepage role-guide tiles use :height: purely for layout, so clicking a tile image opened the raw PNG instead of navigating to the linked page (fixes openedx#1479).
|
Thanks for the pull request, @deepusnath! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
| # `:height:`, `:width:`, or `:scale:` option) to their own unscaled file. | ||
| # Our role-guide tiles use `:height:` purely for layout, so this made | ||
| # clicking a tile image open the raw image instead of the linked page. | ||
| html_scaled_image_link = False |
There was a problem hiding this comment.
This fixes the clicking the tile linking to a raw image issue, but doesn't actually fix the problem of the homepage images linking to the page (now clicking the image just does nothing; see https://docsopenedxorg--1513.org.readthedocs.build/en/1513/)
I also don't actually think we want this, though. There are plenty of images within docs pages that have text that's a bit hard to see when you are looking at the docs page, and being able to click on the image to enlarge it is really helpful.
Do you think there's a way to fix, very specifically, the images on the homepage linking to the pages - so here,
clicking on the image would link to the "Educator's Home", without destroying the ability to enlarge other site images?
Replaces the previous approach, which set html_scaled_image_link = False site-wide. That stopped the tile images from opening the raw PNG, but it also removed click-to-enlarge from every scaled image in the docs, and left the tiles inert rather than linking anywhere. Instead, give each homepage grid-item-card a 🔗/:link-type: option. sphinx-design renders that as an sd-stretched-link overlay covering the whole card, so clicking anywhere on a tile -- image included -- navigates to that role's home page. Scaled images elsewhere keep their default link to the full-size file. Verified in a browser against a full site build: clicking each of the seven tile images navigates to its target page, and a scaled screenshot on a docs page still links to the image for enlarging.
|
Good catch on both counts — you're right that click-to-enlarge is worth keeping, and that the tiles were left inert rather than actually linking. I've reverted the conf.py change entirely and taken the scoped approach instead. Each homepage grid-item-card now gets 🔗 / :link-type: doc, which sphinx-design renders as an sd-stretched-link overlay spanning the whole card. Clicking anywhere on a tile — image included — navigates to that role's home page, and image link behavior everywhere else in the docs is untouched. Verified in a browser against a full site build: All 7 tile images (6 role guides + Core Contributors Handbook) navigate to their target pages. One thing worth flagging for your judgment: I applied this to the seven cards that have a single unambiguous destination. I deliberately left the "What's New?", "Quick Starts", "Release Notes", and "Help & Feedback" cards alone, since those contain multiple links or a toctree and a whole-card link would swallow the individual ones. Happy to adjust if you'd rather handle those differently. |
|
Hi @deepusnath - the language of this comment strongly suggests to me that you're running this code, and my human code review, through an LLM and simply pasting its output. Please review our AI Contribution Policy: https://github.com/openedx/.github/blob/master/AI_POLICY.md and please disclose where you are using AI, and how you are ensuring that human eyes remain in the loop. |
Sphinx's html_scaled_image_link defaults to True, which auto-wraps any image using :height:, :width:, or :scale: in a link to its own unscaled file. The homepage role-guide tiles use :height: purely for layout, so clicking a tile image opened the raw PNG instead of navigating to the linked page (fixes #1479).