pull/318/merge
Charles Fulton 1 year ago committed by GitHub
commit e02e1e6e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -274,6 +274,11 @@ const OPTIONS = {
choices: ['first', 'spread', 'random'],
'default': 'first'
},
'album-covers': {
group: 'Album options:',
description: 'Optional overrides for album previews',
type: 'string'
},
// ------------------------------------
// Website options

@ -122,6 +122,21 @@ Album.prototype.sort = function (options) {
}
Album.prototype.pickPreviews = function (options) {
// Read in the optional covers.
if (options.albumCovers) {
const covers = require(options.albumCovers)
if(covers[this.basename]) {
let count = 0
do {
if (this.files[count].path === covers[this.basename]) {
this.previews = [this.files[count]]
}
count = count + 1
} while (!this.previews || count < this.files.length)
}
}
if (!this.previews) {
// consider nested albums if there aren't enough photos
var potential = this.files
if (potential.length < PREVIEW_COUNT) {
@ -144,6 +159,7 @@ Album.prototype.pickPreviews = function (options) {
} else {
throw new Error(`Unsupported preview type: ${options.albumPreviews}`)
}
}
// and fill any gap with a placeholder
var missing = PREVIEW_COUNT - this.previews.length

Loading…
Cancel
Save