Jump to content

Extension:HighslideGallery

From mediawiki.org
MediaWiki extensions manual
HighslideGallery
Release status: stable
Implementation Media, Parser function , Tag
Description The HighslideGallery (HSG) extension uses Highslide JS to enable images and YouTube videos to be displayed on the page as resizable thumbnails (or as anchor text) linking to an interactive HSG overlay.
Author(s)
Maintainer(s) David Van Winkle
Latest version 2.1.0 (2025-12-23)
MediaWiki 1.39+
PHP 7.4+
Composer mediawikiext/highslidegallery
$wgHSGControlsPreset
‎<hsgytb>, ‎<hsyoutube>
Licence GNU General Public License 2.0 only
Download
README.md
CHANGELOG.md
Example Developer template page
This extension doesn't fight with core media-presentation functionality (e.g., MultimediaViewer is fully compatible).

Overview

[edit]

The HighslideGallery (HSG) extension uses Highslide JS to enable images and YouTube videos to be displayed on the page as resizable thumbnails (or as anchor text) linking to an interactive HSG overlay. HSG-enabled assets on a page can optionally be grouped into a gallery by assigning a common "gallery ID" to parameter hsgid, regardless of where the assets are shown (or linked) on the page. Inside the HSG overlay, gallery items can be navigated using either the GUI or keyboard. Images too large for the viewport can be expanded to full size with ability to pan over the enlarged image inside the HSG expander using the mouse. Large galleries can leverage the 'play' function, which will sequentially open all images in the gallery. Videos will also be 'played', but it's probably not useful. See this example.

2.0.0+ Breaking Changes

[edit]

The 2.0.0+ release of this extension fixes some long-standing issues and adds some nice new features available in Highslide JS 5.0.0. In fact, this extension also updates Highslide JS to 5.1.0, providing some new core features like toggling full resolution and panning images too large for the viewport. Due to the extensive rewrite, the following will need to be considered if upgrading:

  • Drops support for MediaWiki < 1.39 (ResourceLoader-only, modern hooks)
  • Drops support for the old highslide parameter for gallery grouping ID; instead, use hsgid
  • Replaces legacy caption markup with span-wrapped classes (`hsg-caption-gallery/title/caption`), so some styling elements will require revision.

Installation

[edit]

If the $wgExtensionAssetsPath value was customized in LocalSettings.php, update hs.graphicsDir in modules/highslide.cfg.js to match that path.

Composer (recommended)

[edit]

Add to composer.local.json:

{
  "require": {
    "mediawikiext/highslidegallery": "^2.0"
  },
  "extra": {
    "merge-plugin": {
      "include": [
        "extensions/*/composer.json"
      ]
    }
  }
}


Then run:

composer update mediawikiext/highslidegallery -W


This installs into extensions/HighslideGallery/ from Packagist.

Manual (archive)

[edit]
  1. Download a tagged release (e.g., `v2.0.0`) and extract into extensions/HighslideGallery/.
  2. Ensure extension.json, modules/, and PHP sources are present.

Post-install

[edit]

In LocalSettings.php:

wfLoadExtension( 'HighslideGallery' );

Optionally, configure the HSG controls to be centered above the overlay expander rather than at bottom of the viewport (default if this isn't set):

$wgHSGControlsPreset = 'stacked-top';
  • modules/highslide.cfg.js for overlay behavior (margins, zoom, controls).
  • modules/highslide.override.css for styling (SVG controls, thumbstrip, captions).

More configuration details can be found below.

Usage

[edit]

See the developers' wiki for an implemented example of this extension.

Parser functions (modern)

[edit]

- Image (#hsgimg):

{{#hsgimg:source=File:Pic.jpg|hsgid=GalleryA|width=210|title=Title|caption=Caption|inline=0|nocaption=0|linktext=Inline link text}}

- YouTube (#hsgytb):

{{#hsgytb:VIDEO_ID|hsgid=GalleryA|width=210|title=Title|caption=Caption|inline=0|autoplay=0}}
Parameters (named; positional source is supported as first declaration)
Parameter Description Status
source File|Image:{{PAGENAME}} or external URL (image) / YouTube ID or URL (video) required
hsgid slideshow gallery id; shown as the first label term in overlay optional
tile setting to '1' triggers tiling mode optional
width max thumb width in px (default 210) optional
title thumb/overlay title text; used in alt text for SEO optional
caption thumb/overlay caption text; used in alt text for SEO optional
nocaption setting to '1' or 'true' hides thumb (not overlay) title/caption optional
inline setting to '1' triggers inline mode optional
linktext inline link text optional
autoplay video ONLY; enables autoplay (muted) optional

Examples

[edit]

Using the raw parser functions directly:

  • Inline image with custom link text:
    {{#hsgimg:source=File:Pic.jpg|hsgid=GalleryA|inline=1|linktext=See image|title=Sunset|caption=Lake view}}
    
  • Mixed gallery (images + video) with captions and default thumbs:
    {{#hsgimg:source=File:Pic1.jpg|hsgid=GalleryMixed|title=Title1|caption=Caption1}}
    
    {{#hsgimg:source=File:Pic2.jpg|hsgid=GalleryMixed|title=Title2|caption=Caption2}}
    
    {{#hsgytb:source=VIDEO_ID|hsgid=GalleryMixed|title=Clip|caption=Gameplay}}
    
  • Legacy YouTube tag (still parsed; inline only; prefer #hsgytb for modern usage):
    <hsyoutube title="Trailer">https://www.youtube.com/watch?v=VIDEO_ID</hsyoutube>
    

Example Template

[edit]

Leveraging all features of the extension:

<includeonly>
{{#if: {{{ytb|}}}
| <!-- YOUTUBE BRANCH -->
{{#hsgytb:
| source={{{ytb|}}}
| hsgid={{{hsgid|}}}
| tile={{{tile|0}}}
| width={{{width|}}}
| title={{{title|}}}
| caption={{{caption|}}}
| nocaption={{{nocaption|0}}}
| inline={{{inline|0}}}
| linktext={{{linktext|}}}
| autoplay={{{autoplay|}}}
}}
| <!-- IMAGE BRANCH (default when no ytb) -->
{{#hsgimg:
| source={{{img|}}}
| hsgid={{{hsgid|}}}
| tile={{{tile|0}}}
| width={{{width|}}}
| title={{{title|}}}
| caption={{{caption|}}}
| nocaption={{{nocaption|0}}}
| inline={{{inline|0}}}
| linktext={{{linktext|}}}
}} }}
</includeonly>

Understanding Content Types & Galleries

[edit]

HSG supports three types of content, all of which can coexist in a single slideshow gallery:

  1. Internal Wiki Files
    [[File:…]] or [[Image:…]]
    Use the {{#hsgimg:…}} parser function to integrate internal wiki files into HSG galleries. While MediaWiki's native [[File:Example.jpg|thumb|…]] syntax still works, it renders standard MediaWiki thumbnails without HSG functionality. To use HSG with internal files, pass the file title to {{#hsgimg:source=File:Example.jpg|hsgid=GalleryA|…}} instead. Internal files, external images, and YouTube videos can exist in the same slideshow by using the same hsgid=.
  2. External Images
    {{#hsgimg:…}}
    Use the parser function for images not stored on the wiki (arbitrary external URLs). These can be grouped with the same hsgid= as internal files or YouTube videos to create mixed-content galleries.
  3. YouTube Videos
    {{#hsgytb:…}} or ‎<hsgytb>...‎</hsgytb>
    Embed videos either as inline text links or thumbnail previews (using the YouTube preview image from img.youtube.com). The inline= parameter controls this. Videos can be grouped into the same hsgid= as images.
[edit]

When multiple media items share the same hsgid=, they form a single slideshow group. The viewer opens one item and can navigate to others in that group using the slideshow controls. This works across content types. I.e., a gallery works with internal images, external images, and YouTube videos all grouped under hsgid=MyGallery.

Tiling layouts (opt-in)

[edit]
  • Default thumbs are resizable using custom width=# (px). To tile responsively (i.e., 'justified' thumbs), set tile=1 on all thumbs that declare a common hsgid; the auto wrapper gets hsg-tiles-horizontal. Control sizing with CSS variables, --hsg-tile-min and --hsg-tile-gap, in highslide.override.css.
  • Inline width= values on thumbs are otherwise overridden inside the tiling wrappers.

Legacy tags (still supported)

[edit]
  • YouTube tag: ‎<hsyoutube title="Trailer">https://www.youtube.com/watch?v=VIDEO_ID‎</hsyoutube> (defaults to inline). Prefer #hsgytb for modern usage.
  • Note: The extension no longer accepts [[File:…|hsgid=…]] syntax to invoke HSG; use {{#hsgimg:source=File:…|hsgid=…}} instead. Legacy hsgid=/highslide= prefixes in captions are parsed for backward compatibility but do not activate HSG on native file links.

Guarantees & Limitations

[edit]
  • Image clicks do not close overlays — Viewers must use the close button, press Esc, or click the dimmed margin to close. This prevents accidental exits when interacting with the image.
  • Clean HTML — HSG prevents malformed captions and ensures consistent markup. External and internal images both get proper alt text and title attributes.
  • Responsive overlays — Overlays auto-fit to the viewport with sensible margins (configurable at the top pf highslide.cfg.js), and images can be zoomed to full size with panning.
  • Gallery index — When viewing a multi-image gallery, the overlay displays "1 of N" so viewers know their position.
  • Zoom UI controls — The zoom helper exists and works programmatically, but manual UI buttons (zoom in/zoom out) are not wired into the overlay, nor are there plans to do so unless the need arises. Possible workaround: use keyboard or browser zoom.
  • Caption HTML detection — HSG uses a simple heuristic to detect HTML in captions. If captions have unusual formats, they may not render as expected. For complex HTML, consider using a template.

Compatibility with Other MediaWiki Features

[edit]
  • MediaViewer — HSG thumbnails are automatically marked with the noviewer class to prevent MediaViewer from interfering with HSG overlays. HSG completely replaces MediaViewer for images created via {{#hsgimg:…}}.
  • Standard MediaWiki [[File:…]] syntax — Native MediaWiki file links continue to work as usual and are not affected by HSG. Use {{#hsgimg:…}} to enable HSG popups for internal files.
  • Other galleries (‎<gallery> tag, etc.) — HSG does not interfere with other gallery implementations; the extension targets only media created via its parser functions.

Customization via JS and CSS Variables

[edit]

HSG exposes several convenience variables and CSS custom properties (CSS variables) that can be adjusted via custom styles or LocalSettings without modifying extension code. This prevents conflicts and makes updates safe.

JavaScript Configuration

[edit]

modules/highslide.cfg.js The following hs.* properties are exposed and can be overridden via custom JS:

Overlay behavior

  • hs.align (default: 'center') — Horizontal alignment of the overlay
  • hs.marginTop, hs.marginBottom, hs.marginLeft, hs.marginRight (px) — Viewport margins around overlay
  • hs.dimmingOpacity (default: 0.75) — Opacity of the background dimmer (0–1)
  • hs.closeOnClick (default: false) — Whether clicking the image closes the overlay (HSG forces false to prevent accidental closes)
  • hs.allowSizeReduction (default: true) — Allow shrinking overlays to fit viewport
  • hs.showCredits (default: false) — Show Highslide credits in overlay
  • hs.outlineType (default: null) — Outline style; HSG uses CSS-driven styling

Transitions (can be toggled for different effects)

  • hs.restoreDuration (d)efault: 250) — Duration of zoom out on closing the overlay
  • hs.expandDuration, hs.restoreDuration (default: 0 ms) — Animation timing
  • hs.transitions (default: []) — Array of transition effects; try ['expand', 'crossfade'] for classic behavior
  • hs.transitionDuration (d)efault: 250) — duration of ANY enabled transitions/animations of images, captions, or overlay

Gallery display

  • hs.numberPosition (default: 'caption') — Where "1 of N" appears ('caption', 'top-left', 'bottom-left', etc.)
  • hs.wrapperClassName (default: 'hsg-frame floating-caption') — CSS classes applied to the overlay wrapper

To override, add JavaScript to LocalSettings.php or custom JS file after HighslideGallery is loaded:

// Example: Increase margins, enable fade transitions
if ( typeof hs !== 'undefined' ) {
    hs.marginTop = 60;
    hs.marginBottom = 60;
    hs.expandDuration = 200;
}

CSS Custom Properties

[edit]

modules/highslide.override.css The following CSS variables are defined in :root and can be overridden via custom CSS stylesheet: Colors

  • --hsg-caption-number (default: #777) — Gallery index text ("1 of 5") color
  • --hsg-caption-gallery (default: #b0b0b0) — Gallery title color
  • --hsg-caption-title (default: #b0b0b0) — Overlay title color
  • --hsg-caption-caption (default: #ff9012) — Overlay caption text color
  • --hsg-caption-text (default: #777) — General overlay text color
  • --hsg-caption-thumb-title, --hsg-caption-thumb-caption, --hsg-caption-thumb-text — Thumbnail caption colors

Frame and layout

  • --hsg-dimmer (default: rgba(0, 0, 0, 0.75)) — Background dimmer color and opacity
  • --hsg-frame-bg (default: #000) — Overlay frame background color
  • --hsg-frame-border (default: #888) — Frame border color
  • --hsg-frame-shadow (default: rgba(0, 0, 0, 0.9)) — Frame shadow color
  • --hsg-ytb-bg (default: #000) — YouTube embed background

Responsive tiling

  • --hsg-tile-min (default: 210px) — Minimum thumbnail width in responsive tiling layouts (when tile=1)
  • --hsg-tile-gap (default: 12px) — Gap between tiled thumbnails

Thumbnails and controls

  • --hsg-ts-border (default: #ff9012) — Thumbstrip (slideshow navigation) border color
  • --hsg-ts-border-hover (default: #aaa) — Thumbstrip border color on hover

Beware modifications to the following

[edit]
  • hs.graphicsDir — Set this in highslide.cfg.js if $wgExtensionAssetsPath is custom (see Installation section)
  • hs.wrapperClassName — HSG requires 'hsg-frame' for proper styling; modify CSS instead of this property
  • hs.closeOnClick — HSG forces this to false for UX; modifying it will break expected behavior

See also

[edit]