A Sphinx extension to integrate Viewer.js for image zooming into Sphinx documentation (designed for JupyterBook v1).
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
JB1 Zoomies
A simple Sphinx extension to integrate Viewer.js for image zooming in Jupyter Books and Sphinx documentation.
Features
- Pinch & Zoom: Smooth, mobile-friendly zooming for all your images.
- Theme Integrated: Automatically adapts to light and dark modes, using your theme's native colors.
- Smart Captions: Automatically pulls captions from
<figure>elements to display them in the viewer. - Best-Fit Logic: Intelligently scales images to fit your viewport (configurable).
- Dark Mode Optimization: Option to automatically invert image colors in dark mode—perfect for scientific plots with white backgrounds.
- Customizable Toolbar: Choose exactly which tools (zoom, rotate, reset) are available to your readers.
Installation
pip install jb1-zoomies
Or from source:
pip install .
Usage
Jupyter Book
Add the extension to your _config.yml:
sphinx:
extra_extensions:
- jb1_zoomies
Sphinx
Add the extension to your conf.py:
extensions = [
# ...
'jb1_zoomies',
]
Configuration
JB1 Zoomies works out-of-the-box with PyData-based themes (like the Jupyter Book default), but you can fully customize it in your _config.yml (Jupyter Book) or conf.py (Sphinx).
Options
| Option | Default | Description |
|---|---|---|
zoomies_selector |
".bd-article img" |
CSS selector for images that should be zoomable. |
zoomies_best_fit |
70 |
Initial zoom level as a % of the viewport (1-100). |
zoomies_toolbar |
["zoomIn", ...] |
Tools to show. Options: zoomIn, zoomOut, oneToOne, reset, prev, play, next, rotateLeft, rotateRight, flipHorizontal, flipVertical. |
zoomies_invert_colors |
true |
Inverts image colors in dark mode. Useful for charts with white backgrounds. |
zoomies_bg_apply_to_img |
true |
If true, adds a background/padding directly to the image. If false, colors the entire backdrop. |
zoomies_bg_color_light |
"rgba(255, 255, 255, 0.95)" |
Viewer background color in light mode. |
zoomies_bg_color_dark |
"#333" |
Viewer background color in dark mode. |
zoomies_caption_color_light |
"var(--pst-color-text-base)" |
Caption text color in light mode. |
zoomies_caption_color_dark |
"var(--pst-color-text-base)" |
Caption text color in dark mode. |
zoomies_cdn_css |
"...viewer.min.css" |
URL for the Viewer.js CSS file. |
zoomies_cdn_js |
"...viewer.min.js" |
URL for the Viewer.js JS file. |
Example _config.yml (Jupyter Book)
sphinx:
config:
zoomies_selector: ".bd-article img, .my-custom-image-class"
zoomies_best_fit: 85
zoomies_toolbar: ["zoomIn", "zoomOut", "reset", "rotateRight"]
zoomies_invert_colors: false # Disable if your images are already dark-mode friendly
Example conf.py (Sphinx)
zoomies_selector = ".bd-article img"
zoomies_best_fit = 80
zoomies_invert_colors = True
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jb1_zoomies-0.2.1.tar.gz.
File metadata
- Download URL: jb1_zoomies-0.2.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
025c8bd87af0b04ec0cb380a4ab949248b9620e448cfcc30a4605d4e34507eb3
|
|
| MD5 |
ada2055e8080513a554356f317598a18
|
|
| BLAKE2b-256 |
11f13593142a86a6d8d98d6199cefa7d73ff3f96a1569da51cc5c249091cc161
|
File details
Details for the file jb1_zoomies-0.2.1-py3-none-any.whl.
File metadata
- Download URL: jb1_zoomies-0.2.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21eac1108ac0d190806d8fddc709948cd87acc74e0148d53002e2798a74b9aa3
|
|
| MD5 |
f34f089361fc27197ba4711f6e9a0dd7
|
|
| BLAKE2b-256 |
349cacd4cda4ce03f13c5fba5750ef6b7f6e364414f35635a24022bef7f6a1cd
|