Skip to content

Commit d199d22

Browse files
authored
Merge pull request #198 from orionrobots/fix-197
Fix #197
2 parents 122a5dd + 132f61e commit d199d22

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Creative Commons By Attribution Share-Alike v3.0
88
## Running serve and build in docker
99

1010
```bash
11-
docker compose up --rm dist
12-
docker compose run --interactive --rm serve npm install
11+
docker compose up dist
1312
docker compose run --interactive --rm serve npm run dev
1413
docker compose up serve
1514
```

docker-compose.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
services:
22
dist:
3-
image: node:18-bullseye
3+
build:
4+
context: .
5+
dockerfile: Dockerfile.dist
46
command: ["npm", "run", "dist"]
57
volumes:
68
- .:/src
79
working_dir: /src
810

911
dist_clean:
12+
build:
13+
context: .
14+
dockerfile: Dockerfile.dist
1015
volumes:
1116
- .:/src
1217
working_dir: /src
@@ -21,7 +26,9 @@ services:
2126
# - ./_site:/var/www/html
2227

2328
serve:
24-
image: node:18-bullseye
29+
build:
30+
context: .
31+
dockerfile: Dockerfile.dist
2532
volumes:
2633
- .:/src
2734
working_dir: /src

serve.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM node:18-bullseye
2+
# Install dependencies
3+
RUN npm install
4+

src/shortcodes/make_tab_gallery.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,24 @@ async function make_gallery(id, images) {
4949
const description_element = '<div class="image-tab-gallery-description row"></div>';
5050
const current_image_element = '<div class="image-tab-gallery-current-image col-md-5"></div>';
5151

52-
const tabs = images_with_metadata.map(
53-
image => '<div class="image-tab-gallery-tab" title="' + image.alt + '" data-src="' + image.metadata.jpeg[0].url + '">' +
54-
'<img src="' + image.thumb_metadata.jpeg[1].url + '" loading="lazy" decoding="async" width="128" height="112" alt="' + image.alt + '">' +
55-
'</div>');
52+
const tabs = images_with_metadata.map(image => {
53+
let thumbnailUrl = '';
54+
let mainImageUrl = '';
55+
const thumbnailAlt = image.alt || '';
56+
if (image.thumb_metadata?.jpeg?.[1]?.url) {
57+
thumbnailUrl = image.thumb_metadata.jpeg[1].url;
58+
} else {
59+
console.warn(`Tab Gallery: Missing thumbnail for image alt='${thumbnailAlt}'. Falling back to empty src.`);
60+
}
61+
if (image.metadata?.jpeg?.[0]?.url) {
62+
mainImageUrl = image.metadata.jpeg[0].url;
63+
} else {
64+
console.warn(`Tab Gallery: Missing main image for image alt='${thumbnailAlt}'. Falling back to empty src.`);
65+
}
66+
return '<div class="image-tab-gallery-tab" title="' + thumbnailAlt + '" data-src="' + mainImageUrl + '">' +
67+
'<img src="' + thumbnailUrl + '" loading="lazy" decoding="async" width="128" height="112" alt="' + thumbnailAlt + '">' +
68+
'</div>';
69+
});
5670
// put the joined tabs in the tabs element.
5771

5872
const tabs_element = '<div class="image-tab-gallery-tabs col-md-3">' + tabs.join("\n") + '</div>';

0 commit comments

Comments
 (0)