I have a static site in Sphinx and a ton of illustrations. Is there a simple way to integrate lightbox and generate thumbnails automatically?
.. image:: picture.jpeg
:lightbox: true
:width: 200 px
:alt: alternate text
:align: right
Add the sphinxcontrib-images extension to your conf.py file:
extensions = [
…
'sphinxcontrib.images',
…
]
Then use this setting to tell the extension to add lightbox to standard .. image:: calls:
images_config = {
'override_image_directive': True,
}
Or use the thumbnail option .. thumbnail:: picture.png
Be sure to install the extension first: pip install sphinxcontrib-images
For further information, see sphinxcontrib-images homepage at https://github.com/spinus/sphinxcontrib-images
I made a dirty hack solution and paste it here because I'm not sure I want/have time to maintain it. It extends Figure class (to add text below) and abuses download_reference node. It also overrides in non-documented way the app.add_node method (which birkinfeld should have named set_node)
It generates a thumbnail and makes Sphinx put the original image in downloads.
You still need to add jQuery & FancyBox in your templates.
Enjoy
http://pastebin.com/pMhKnTkv
usage:
.. fancyimage:: img/exit_jam.jpg
:fitwidth: 100
:fitheight: 100
:alt: cool
:rel: tst
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With