Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a lightbox extension for Sphinx?

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
like image 405
culebrón Avatar asked Oct 24 '25 19:10

culebrón


2 Answers

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

like image 89
MD004 Avatar answered Oct 26 '25 21:10

MD004


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
like image 34
culebrón Avatar answered Oct 26 '25 21:10

culebrón



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!