Sphinx adds a link to an image or number

In the Sphinx, I'm trying to do something pretty basic. I have some images, but I prefer to keep them pretty small, and I want to allow the user to click on them to get a larger image. I did not find a syntactic way to combine image: or figure: with ref: or link:

 .. image:: _static/my_image_small.png 

and I have in the same folder my_image_large.png .

If you come up with a solution, should the larger image just be a file with an explicit link to it, or create a reSt file with the optional image: tag? An alternative would be to play with the image size in the reSt file, but I still don't know how to create a link from a small image to a large image.

Thanks for helping me.

+8
python-sphinx
source share
1 answer

Just use the target directive. You would have something like:

 .. image:: _static/my_image_small.png :target: _static/my_image_large.png 

It is not necessary to use links to a static folder in your source. In any case, they will be copied to the _images folder when you create the documents (so that you will have them twice in your assemblies without requiring them there).

I always use the folder under the numbers next to the source folder where I manage the images. However, you want to put my_image_large.png files in the _static folder, because the contents will be copied during assembly.

+6
source share

All Articles