Skip to content

Commit

Permalink
allow setting a different extension than .jpg for router pictures
Browse files Browse the repository at this point in the history
  • Loading branch information
maurerle committed Aug 19, 2023
1 parent 63814b8 commit 41c489d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ var firmwarewizard = function() {
PREVIEW_PICTURES_DIR = config.preview_pictures;
}

var PREVIEW_PICTURES_EXT = '.jpg';
if(config.preview_pictures_ext !== undefined) {
PREVIEW_PICTURES_EXT = config.preview_pictures_ext;
}

var enabled_device_categories = ['recommended'];
if ("enabled_device_categories" in config) {
enabled_device_categories = config.enabled_device_categories;
Expand Down Expand Up @@ -502,7 +507,7 @@ var firmwarewizard = function() {
'version': version,
'location': location,
'size': size,
'preview': preview+".jpg",
'preview': preview,
'category': device.category
});
}
Expand Down Expand Up @@ -670,7 +675,7 @@ var firmwarewizard = function() {

var image = document.createElement('img');

image.src = PREVIEW_PICTURES_DIR+images[vendor][model][latestRevisionIndex].preview;
image.src = PREVIEW_PICTURES_DIR+images[vendor][model][latestRevisionIndex].preview+PREVIEW_PICTURES_EXT;
image.alt = name;
image.addEventListener('error', firmwarewizard.setDefaultImg);

Expand Down Expand Up @@ -698,7 +703,7 @@ var firmwarewizard = function() {
}

function setDefaultImg(e) {
fallbackImg = PREVIEW_PICTURES_DIR+'no_picture_available.jpg';
fallbackImg = 'pictures/no_picture_available.jpg';
if (e.target.src.indexOf(fallbackImg) == -1) {
e.target.src = fallbackImg;
}
Expand Down
1 change: 1 addition & 0 deletions config_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var config = {
experimental_branches: ['experimental'],
// path to preview pictures directory
preview_pictures: 'pictures/',
preview_pictures_ext: '.jpg',
// link to changelog
changelog: 'CHANGELOG.html',
// links for instructions like flashing of certain devices (optional)
Expand Down

0 comments on commit 41c489d

Please sign in to comment.