5

I am creating html documentation using sphinx and the read-the-docs theme. When I add a scaled image, it can be clicked and pops-up full-size in a new tab. How can I disable this behavior.

For example, I am using the following scenario throughout my document 1) Create a png file, e.g., application-icon.png , to be exactly 10pt by 10pt. 2) Create a document containing:

.. |application_icon| image:: images/application-icon.png

:width: 10pt

:height: 10pt

Click the application icon |application_icon| to display …"

When the width and height scale information are included, the icon displays perfectly and properly sizes even when I view the document on my cellphone. However, the icon is clickable and opens a new tab showing the image. If I omit the scale information, the icon is no longer clickable, however the image does not scale when the document is opened on my cellphone, instead the image occupies the entire width of the cellphone screen.

FlGal
  • 51
  • 3
  • 1
    I changed: img { width:100%; height:auto } To img { max-width:100%; height:auto } In sphinx-rtd-theme\static\css\theme.css and now images without scale information scale properly on reduced displays. – FlGal Oct 19 '16 at 19:10
  • 1
    For anyone who happens to land here looking for the *opposite* behavior (make images clickable), Sphinx does this automatically, but only when you specify the `scale` attribute on the image or figure. – Soren Bjornstad Aug 18 '20 at 13:41

2 Answers2

5

Try adding html_scaled_image_link = False to your Sphinx conf.py file. You can find details here.

Leila Hadj-Chikh
  • 1,653
  • 17
  • 16
2

Inline

.. image:: images/pic.png
  :class: no-scaled-link

I kept clicking on them when I was switching between windows/ tabs!

Kermit
  • 4,922
  • 4
  • 42
  • 74