A Sphinx extension to integrate Viewer.js for image zooming into Sphinx documentation (designed for JupyterBook v1).
Project description
TeachBooks Zoomies
A simple Sphinx extension to integrate Viewer.js for image zooming in Jupyter Books and Sphinx documentation.
[!NOTE] This extension is based on the original jb-zoomies.
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 teachbooks-zoomies
Usage
Jupyter Book
Add the extension to your _config.yml:
sphinx:
extra_extensions:
- teachbooks_zoomies
Sphinx
Add the extension to your conf.py:
extensions = [
# ...
'teachbooks_zoomies',
]
Configuration
TeachBooks 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", "zoomOut", "oneToOne", "reset"] |
Tools to show. Options: zoomIn, zoomOut, oneToOne, reset, prev, play, next, rotateLeft, rotateRight, flipHorizontal, flipVertical. |
zoomies_invert_colors |
false |
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
Example conf.py (Sphinx)
zoomies_selector = ".bd-article img"
zoomies_best_fit = 80
zoomies_invert_colors = True
Project details
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 teachbooks_zoomies-0.2.1.tar.gz.
File metadata
- Download URL: teachbooks_zoomies-0.2.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b81f8d6b07e47984c190595c0510d2332d5058313abd51211a3512db9995e440
|
|
| MD5 |
7a4e798730c6fc06b2e71d1408436f83
|
|
| BLAKE2b-256 |
88ba74dcfe3491e565ca657e50819115379ff58e7814ce7409954fee73a9f92e
|
Provenance
The following attestation bundles were made for teachbooks_zoomies-0.2.1.tar.gz:
Publisher:
python-publish.yml on TeachBooks/TeachBooks-Zoomies
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
teachbooks_zoomies-0.2.1.tar.gz -
Subject digest:
b81f8d6b07e47984c190595c0510d2332d5058313abd51211a3512db9995e440 - Sigstore transparency entry: 991581161
- Sigstore integration time:
-
Permalink:
TeachBooks/TeachBooks-Zoomies@85e0a18639d3c2a4b719bed1310a04b4d894ae4d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/TeachBooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@85e0a18639d3c2a4b719bed1310a04b4d894ae4d -
Trigger Event:
push
-
Statement type:
File details
Details for the file teachbooks_zoomies-0.2.1-py3-none-any.whl.
File metadata
- Download URL: teachbooks_zoomies-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dd39352ddafb48ed872e33e3bfc8d6c220d0e4c0f615abfe6b553a223c4f4c5
|
|
| MD5 |
e43ac53f545b6a198d6d338743fa9148
|
|
| BLAKE2b-256 |
0fb3a33ad4c92f039687aa01313ae262970272280269daa83a2a981642cb8619
|
Provenance
The following attestation bundles were made for teachbooks_zoomies-0.2.1-py3-none-any.whl:
Publisher:
python-publish.yml on TeachBooks/TeachBooks-Zoomies
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
teachbooks_zoomies-0.2.1-py3-none-any.whl -
Subject digest:
2dd39352ddafb48ed872e33e3bfc8d6c220d0e4c0f615abfe6b553a223c4f4c5 - Sigstore transparency entry: 991581164
- Sigstore integration time:
-
Permalink:
TeachBooks/TeachBooks-Zoomies@85e0a18639d3c2a4b719bed1310a04b4d894ae4d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/TeachBooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@85e0a18639d3c2a4b719bed1310a04b4d894ae4d -
Trigger Event:
push
-
Statement type: