Add ImageGallery shortcode with Lightbox2 support#11
Conversation
Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/0a97ea5e-9c2b-4e78-bd4b-7898c0595a54 Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
… to README CDN links Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/0a97ea5e-9c2b-4e78-bd4b-7898c0595a54 Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
…ADME Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/0a97ea5e-9c2b-4e78-bd4b-7898c0595a54 Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
|
@copilot add lightbox2 options |
Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/989524cf-c5c6-4722-ba96-180f23588df0 Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/989524cf-c5c6-4722-ba96-180f23588df0 Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Done in commit The shortcode now supports all Lightbox2 options: New gallery-level parameters (emits a
Per-image Example: |
|
@copilot update the site project in the sample folder to use the gallery plugin and confirm the plugin is working |
…JS to layout Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/4a9074ae-b427-477b-bc40-7d96900d585a Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/4a9074ae-b427-477b-bc40-7d96900d585a Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Done in commit Changes made to the sample project:
Running <div class="image-gallery">
<a href="/posts/images/background.jpg" data-lightbox="my-gallery" data-title="Background" data-alt="Background">
<img src="/posts/images/background.jpg" alt="Background" />
</a>
</div>
<script>
lightbox.option({
'wrapAround': true
});
</script>Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot does it need to be dist/js/lightbox-plus-jquery.min.js.map instead? Also could you use _head and _scripts files to put these items in instead? |
…query bundle Agent-Logs-Url: https://github.com/AlexHedley/statiq.plugins/sessions/4afb431c-f3ba-4cd8-8382-850a286eec7f Co-authored-by: AlexHedley <1573469+AlexHedley@users.noreply.github.com>
Done in commit
|
|
@copilot share some screenshots of the gallery in action from the sample site |
Here are the screenshots from the sample site running the Gallery thumbnails (three images rendered side-by-side): Lightbox2 overlay (clicking an image opens the full-screen lightbox, with the title "Mountain Landscape" and "Photo 1 of 3" counter from the The Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|


Implements a Statiq
IShortcodethat renders an inline image gallery using Lightbox2, allowing images to be cycled through in a fullscreen overlay.New components
ImageGalleryShortcode(SyncShortcode) — parses newline-separated image entries from shortcode content (src,src|title, orsrc|title|alt), HTML-encodes all attribute values, strips Markdown-injected HTML tags from content lines, and emits Lightbox2-compatible markup with full configuration option supportImageGalleryConfigurator(IConfigurator<Bootstrapper>) — registers the shortcode asImageGallery, following the existingReadingTimeConfiguratorpatternUsage
Parameters:
NamegalleryClass<div>.AlbumLabel"Image %1 of %2"%1= current,%2= total).WrapAroundfalseDisableScrollingfalseFadeDuration300ImageFadeDuration300ResizeDuration700FitImagesInViewporttrueShowImageNumberLabeltrueAlbumLabeltext in the lightbox.MaxWidthMaxHeightOutput:
When any Lightbox2 JS options are provided, a
<script>lightbox.option({...});</script>block is emitted after the gallery markup. String values are JS-escaped to prevent injection.Requires Lightbox2 CSS/JS in the layout — CDN links and SRI hash generation guidance included in the README.
Sample project
The
sample/site project is wired up to demonstrate the plugin end-to-end:sample/Program.cs: registersImageGalleryConfiguratorviaAddConfigurator<Bootstrapper>(new ImageGalleryConfigurator())sample/input/posts/_partials/_head.cshtml: Lightbox2 CSS<link>tag, included via@Html.Partial("_partials/_head")in the layout<head>sample/input/posts/_partials/_scripts.cshtml: Lightbox2 JS<script>tag using the jQuery-bundled build (lightbox-plus-jquery.min.js), included via@Html.Partial("_partials/_scripts")before</body>sample/input/posts/_layout.cshtml: references the_headand_scriptspartials instead of inline CDN tagssample/input/posts/1.md: uses theImageGalleryshortcode withWrapAround=trueto demonstrate the plugin in actionRunning
dotnet runin the sample directory generates correct Lightbox2 markup inoutput/posts/1.html.