|
|
|
@ -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
|
|
|
|
|