Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ Object.defineProperty(Album.prototype, 'uri', {
configurable: true
});

/**
* Get an url for the cover image.
*
* @param {String} size image size
* @api public
*/

Album.prototype.coverUrl = function (size) {
if (!size) {
size = 'DEFAULT';
}
if (!this._spotify.sourceUrls[size]) {
throw new Error('Unknown cover size: ' + size);
}
if !(this.cover) {
return null;
}
var res = this.cover.filter(function (e) {
return (e.size === size);
});
if (res.length > 0) {
return this._spotify.sourceUrls[size] + util.gid2id(res[0].fileId);
}
return null;
}

/**
* Loads all the metadata for this Album instance. Useful for when you get an only
* partially filled Album instance from an Album instance for example.
Expand Down