factor device pixel ratio into downloaded image size
This commit is contained in:
parent
8cadabcbe5
commit
5677ce1011
27 changed files with 295 additions and 195 deletions
|
@ -2197,35 +2197,28 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
|
||||
return self.getUrl(url, options);
|
||||
};
|
||||
|
||||
self.getScaledImageUrl = function (itemId, options) {
|
||||
|
||||
/**
|
||||
* Constructs a url for an item logo image
|
||||
* If the item doesn't have a logo, it will inherit a logo from a parent
|
||||
* @param {Object} item A BaseItem
|
||||
* @param {Object} options
|
||||
* Options supports the following properties:
|
||||
* width - download the image at a fixed width
|
||||
* height - download the image at a fixed height
|
||||
* maxWidth - download the image at a maxWidth
|
||||
* maxHeight - download the image at a maxHeight
|
||||
* quality - A scale of 0-100. This should almost always be omitted as the default will suffice.
|
||||
* For best results do not specify both width and height together, as aspect ratio might be altered.
|
||||
*/
|
||||
self.getLogoImageUrl = function (item, options) {
|
||||
|
||||
if (!item) {
|
||||
throw new Error("null item");
|
||||
if (!itemId) {
|
||||
throw new Error("itemId cannot be empty");
|
||||
}
|
||||
|
||||
options = options || {
|
||||
options = options || {};
|
||||
|
||||
};
|
||||
var url = "Items/" + itemId + "/Images/" + options.type;
|
||||
|
||||
options.imageType = "logo";
|
||||
if (options.index != null) {
|
||||
url += "/" + options.index;
|
||||
}
|
||||
|
||||
var logoItemId = item.ImageTags && item.ImageTags.Logo ? item.Id : item.ParentLogoItemId;
|
||||
// Don't put these on the query string
|
||||
delete options.type;
|
||||
delete options.index;
|
||||
|
||||
return logoItemId ? self.getImageUrl(logoItemId, options) : null;
|
||||
normalizeImageOptions(options);
|
||||
|
||||
return self.getUrl(url, options);
|
||||
};
|
||||
|
||||
self.getThumbImageUrl = function (item, options) {
|
||||
|
@ -2245,58 +2238,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
return itemId ? self.getImageUrl(itemId, options) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs an array of backdrop image url's for an item
|
||||
* If the item doesn't have any backdrops, it will inherit them from a parent
|
||||
* @param {Object} item A BaseItem
|
||||
* @param {Object} options
|
||||
* Options supports the following properties:
|
||||
* width - download the image at a fixed width
|
||||
* height - download the image at a fixed height
|
||||
* maxWidth - download the image at a maxWidth
|
||||
* maxHeight - download the image at a maxHeight
|
||||
* quality - A scale of 0-100. This should almost always be omitted as the default will suffice.
|
||||
* For best results do not specify both width and height together, as aspect ratio might be altered.
|
||||
*/
|
||||
self.getBackdropImageUrl = function (item, options) {
|
||||
|
||||
if (!item) {
|
||||
throw new Error("null item");
|
||||
}
|
||||
|
||||
options = options || {
|
||||
|
||||
};
|
||||
|
||||
options.imageType = "backdrop";
|
||||
|
||||
var backdropItemId;
|
||||
var backdropCount;
|
||||
|
||||
if (!item.BackdropCount) {
|
||||
backdropItemId = item.ParentBackdropItemId;
|
||||
backdropCount = item.ParentBackdropCount || 0;
|
||||
} else {
|
||||
backdropItemId = item.Id;
|
||||
backdropCount = item.BackdropCount;
|
||||
}
|
||||
|
||||
if (!backdropItemId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var files = [];
|
||||
|
||||
for (var i = 0; i < backdropCount; i++) {
|
||||
|
||||
options.imageIndex = i;
|
||||
|
||||
files[i] = self.getImageUrl(backdropItemId, options);
|
||||
}
|
||||
|
||||
return files;
|
||||
};
|
||||
|
||||
/**
|
||||
* Authenticates a user
|
||||
* @param {String} name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue