3

I'm using Lightbox 2 for an image set. When a visitor of my website clicks on a thumbnail in that set, it'll show:

  • The enlarged version of the image
  • Underneath that: the description (taken from the <a> title attribute)
  • Underneath that: the text 'Image x of x' ('Image 1 of 12', for example)

Does anyone know where to translate/change the 'Image x of x' text? I've searched through the Lightbox script and CSS files, but can't find the text anywhere.

Some additional info: I'm not using Wordpress or Drupal or any other CMS. I've found some solutions for the issue above, but these all point to files that only seem come with the Lightbox plugins for these CMSes.

ztirom
  • 4,382
  • 3
  • 28
  • 39
Edward Touw
  • 773
  • 1
  • 6
  • 10

3 Answers3

18

With newer lightbox versions, you can use it like other options: Example:

lightbox.option({
    'resizeDuration': 200,
    'wrapAround': true,
    'showImageNumberLabel': true,
    'albumLabel': 'Bild %1 von %2',
});
RonaldPK
  • 760
  • 4
  • 18
Roemer
  • 2,012
  • 1
  • 24
  • 26
7

Take a look in /js/lightbox.js at line 29-31:

LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) {
  return "Image " + curImageNum + " of " + albumSize;
};

Translate the strings in any language / text you want to.

Based on this version: https://github.com/lokesh/lightbox2/blob/master/js/lightbox.js

ztirom
  • 4,382
  • 3
  • 28
  • 39
  • Some additional info for others that might be looking for this solution: in my case the file mentioned in ztirom's answer was located at `/js/lightbox-2.6.min.js`. – Edward Touw Dec 24 '13 at 12:42
  • This is a really poor solution. In case you are using npm, yarn or whatever and you reinstall or update your project, you loose these changes. – jirig Jun 04 '18 at 00:08
0

You can also just use the global object to set the value:

let category = 'Flowers';
lightbox.options.albumLabel = 'Image %1 of %2 - ' + category;
Sigurd Mazanti
  • 2,098
  • 1
  • 8
  • 24