Image Galleries¶
Create beautiful, responsive image galleries with built-in lightbox functionality for an enhanced viewing experience.
Overview¶
Our image gallery features include:
- Responsive Grid Layouts - Automatically adjust to screen size
- Lightbox Viewing - Full-screen image viewing with navigation
- Dark Mode Support - Galleries adapt to your theme
- Lazy Loading - Improved performance for image-heavy pages
- Captions - Add descriptions to your images
- Touch Support - Swipe navigation on mobile devices
Basic Image Gallery¶
Create a simple image gallery using HTML:
<div class="image-gallery">
<figure>
<img loading="lazy" src="../assets/images/dashboard.svg" alt="Dashboard View">
<figcaption>Main Dashboard</figcaption>
</figure>
<figure>
<img loading="lazy" src="../assets/images/analytics.svg" alt="Analytics">
<figcaption>Analytics Panel</figcaption>
</figure>
<figure>
<img loading="lazy" src="../assets/images/settings.svg" alt="Settings">
<figcaption>Settings Page</figcaption>
</figure>
</div>
Markdown Images with Lightbox¶
All images automatically get lightbox functionality:
Click the image above to view in lightbox
Image with Custom Caption¶
Use attributes to add captions:
{: caption="Complete workflow from start to finish"}
Gallery Layouts¶
Grid Gallery¶
Diagram Gallery¶
Combine diagrams with descriptions:
System Architecture
Lightbox Features¶
Navigation¶
When viewing images in lightbox:
- Next/Previous: Use arrow keys or swipe
- Close: Press ESC or click outside
- Zoom: Scroll or pinch to zoom
- Download: Right-click to save
Excluding Images¶
Prevent specific images from opening in lightbox:
Gallery Groups¶
Group related images for sequential viewing:
<div class="gallery-group" data-gallery="screenshots">
<img loading="lazy" src="screen1.png" alt="Screenshot 1">
<img loading="lazy" src="screen2.png" alt="Screenshot 2">
<img loading="lazy" src="screen3.png" alt="Screenshot 3">
</div>
Advanced Features¶
Lazy Loading¶
Improve performance with lazy loading:
Responsive Images¶
Provide different image sizes:
<picture>
<source media="(max-width: 768px)" srcset="image-mobile.png">
<source media="(max-width: 1200px)" srcset="image-tablet.png">
<img loading="lazy" src="image-desktop.png" alt="Responsive Image">
</picture>
Zoom on Hover¶
Add zoom effect to gallery items:
<div class="image-gallery zoom-on-hover">
<figure>
<img loading="lazy" src="image.png" alt="Zoomable">
</figure>
</div>
Configuration¶
GLightbox Options¶
The lightbox is configured in mkdocs.yml
:
plugins:
- glightbox:
touchNavigation: true
loop: false
effect: zoom
slide_effect: slide
width: 100%
height: auto
zoomable: true
draggable: true
auto_theme: true
Custom Styling¶
Override gallery styles in your custom CSS:
/* Custom gallery spacing */
.image-gallery {
gap: 2rem;
margin: 3rem 0;
}
/* Custom caption style */
.image-gallery figcaption {
font-weight: bold;
color: var(--md-primary-fg-color);
}
Best Practices¶
1. Image Optimization¶
- Use appropriate formats (WebP, JPEG, PNG)
- Compress images without quality loss
- Provide responsive sizes
- Use lazy loading for large galleries
2. Accessibility¶
Always provide meaningful alt text:
3. Performance¶
For many images:
<!-- Use lazy loading -->
<img src="image.png" loading="lazy" alt="Description">
<!-- Specify dimensions -->
<img loading="lazy" src="image.png" width="800" height="600" alt="Description">
4. Mobile Experience¶
- Test swipe gestures
- Ensure touch targets are large enough
- Verify images scale properly
- Check loading performance
Examples¶
Screenshot Gallery¶
Architecture Diagrams¶
Microservices Architecture
Troubleshooting¶
Images Not Opening in Lightbox¶
- Check JavaScript console for errors
- Verify GLightbox plugin is enabled
- Ensure image has proper
src
attribute - Check for
no-lightbox
class
Gallery Layout Issues¶
- Verify CSS is loaded
- Check for conflicting styles
- Test in different browsers
- Validate HTML structure
Performance Problems¶
- Implement lazy loading
- Optimize image sizes
- Use appropriate formats
- Enable browser caching
Related Features¶
- Diagrams - Create diagrams with Mermaid and PlantUML
- Mathematical Notation - Display equations
- Content Tabs - Organize content in tabs