Improve image size handling
This commit is contained in:
parent
0397283599
commit
8646b66f6c
11 changed files with 24 additions and 26 deletions
|
@ -2,7 +2,6 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
|
||||||
function (datetime, imageLoader, connectionManager, itemHelper, focusManager, indicators, globalize, layoutManager, appHost, dom, browser, playbackManager, itemShortcuts, imageHelper) {
|
function (datetime, imageLoader, connectionManager, itemHelper, focusManager, indicators, globalize, layoutManager, appHost, dom, browser, playbackManager, itemShortcuts, imageHelper) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var devicePixelRatio = window.devicePixelRatio || 1;
|
|
||||||
var enableFocusTransform = !browser.slow && !browser.edge;
|
var enableFocusTransform = !browser.slow && !browser.edge;
|
||||||
|
|
||||||
function getCardsHtml(items, options) {
|
function getCardsHtml(items, options) {
|
||||||
|
@ -592,7 +591,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'itemHelper', 'focusMana
|
||||||
});
|
});
|
||||||
} else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
} else if (item.AlbumId && item.AlbumPrimaryImageTag) {
|
||||||
|
|
||||||
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
|
height = width && primaryImageAspectRatio ? Math.round(width / primaryImageAspectRatio) : null;
|
||||||
|
|
||||||
imgUrl = apiClient.getScaledImageUrl(item.AlbumId, {
|
imgUrl = apiClient.getScaledImageUrl(item.AlbumId, {
|
||||||
type: "Primary",
|
type: "Primary",
|
||||||
|
|
|
@ -68,7 +68,7 @@ define(['datetime', 'imageLoader', 'connectionManager', 'layoutManager', 'browse
|
||||||
|
|
||||||
return apiClient.getScaledImageUrl(item.Id, {
|
return apiClient.getScaledImageUrl(item.Id, {
|
||||||
|
|
||||||
maxWidth: maxWidth,
|
maxWidth: maxWidth * 2,
|
||||||
tag: chapter.ImageTag,
|
tag: chapter.ImageTag,
|
||||||
type: "Chapter",
|
type: "Chapter",
|
||||||
index: index
|
index: index
|
||||||
|
|
|
@ -114,8 +114,8 @@ define([], function () {
|
||||||
|
|
||||||
var standardWidths = [480, 720, 1280, 1440, 1920, 2560, 3840, 5120, 7680];
|
var standardWidths = [480, 720, 1280, 1440, 1920, 2560, 3840, 5120, 7680];
|
||||||
function getScreenWidth() {
|
function getScreenWidth() {
|
||||||
var width = window.innerWidth * window.devicePixelRatio;
|
var width = window.innerWidth;
|
||||||
var height = window.innerHeight * window.devicePixelRatio;
|
var height = window.innerHeight;
|
||||||
|
|
||||||
if (height > width) {
|
if (height > width) {
|
||||||
/* If we're in portrait, compute the proper width for this height,
|
/* If we're in portrait, compute the proper width for this height,
|
||||||
|
|
|
@ -106,7 +106,7 @@ define(["apphost", "appSettings", "dom", "connectionManager", "loading", "layout
|
||||||
|
|
||||||
if (user.PrimaryImageTag) {
|
if (user.PrimaryImageTag) {
|
||||||
imgUrl = apiClient.getUserImageUrl(user.Id, {
|
imgUrl = apiClient.getUserImageUrl(user.Id, {
|
||||||
width: 300 * window.devicePixelRatio,
|
width: 300,
|
||||||
tag: user.PrimaryImageTag,
|
tag: user.PrimaryImageTag,
|
||||||
type: "Primary"
|
type: "Primary"
|
||||||
});
|
});
|
||||||
|
|
|
@ -493,15 +493,15 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
|
||||||
if (nowPlayingItem.ImageTags && nowPlayingItem.ImageTags.Logo) {
|
if (nowPlayingItem.ImageTags && nowPlayingItem.ImageTags.Logo) {
|
||||||
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.Id, {
|
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.Id, {
|
||||||
tag: nowPlayingItem.ImageTags.Logo,
|
tag: nowPlayingItem.ImageTags.Logo,
|
||||||
maxHeight: 24 * window.devicePixelRatio,
|
maxHeight: 24,
|
||||||
maxWidth: 130 * window.devicePixelRatio,
|
maxWidth: 130,
|
||||||
type: "Logo"
|
type: "Logo"
|
||||||
});
|
});
|
||||||
} else if (nowPlayingItem.ParentLogoImageTag) {
|
} else if (nowPlayingItem.ParentLogoImageTag) {
|
||||||
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.ParentLogoItemId, {
|
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.ParentLogoItemId, {
|
||||||
tag: nowPlayingItem.ParentLogoImageTag,
|
tag: nowPlayingItem.ParentLogoImageTag,
|
||||||
maxHeight: 24 * window.devicePixelRatio,
|
maxHeight: 24,
|
||||||
maxWidth: 130 * window.devicePixelRatio,
|
maxWidth: 130,
|
||||||
type: "Logo"
|
type: "Logo"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,24 +334,24 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
var imgUrl = seriesImageUrl(item, {
|
var imgUrl = seriesImageUrl(item, {
|
||||||
maxWidth: Math.round(dom.getScreenWidth() * 0.20),
|
maxWidth: osdPoster.clientWidth * 2,
|
||||||
type: "Primary"
|
type: "Primary"
|
||||||
}) || seriesImageUrl(item, {
|
}) || seriesImageUrl(item, {
|
||||||
maxWidth: Math.round(dom.getScreenWidth() * 0.20),
|
maxWidth: osdPoster.clientWidth * 2,
|
||||||
type: "Thumb"
|
type: "Thumb"
|
||||||
}) || imageUrl(item, {
|
}) || imageUrl(item, {
|
||||||
maxWidth: Math.round(dom.getScreenWidth() * 0.20),
|
maxWidth: osdPoster.clientWidth * 2,
|
||||||
type: "Primary"
|
type: "Primary"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!imgUrl && secondaryItem && (imgUrl = seriesImageUrl(secondaryItem, {
|
if (!imgUrl && secondaryItem && (imgUrl = seriesImageUrl(secondaryItem, {
|
||||||
maxWidth: Math.round(dom.getScreenWidth() * 0.20),
|
maxWidth: osdPoster.clientWidth * 2,
|
||||||
type: "Primary"
|
type: "Primary"
|
||||||
}) || seriesImageUrl(secondaryItem, {
|
}) || seriesImageUrl(secondaryItem, {
|
||||||
maxWidth: Math.round(dom.getScreenWidth() * 0.20),
|
maxWidth: osdPoster.clientWidth * 2,
|
||||||
type: "Thumb"
|
type: "Thumb"
|
||||||
}) || imageUrl(secondaryItem, {
|
}) || imageUrl(secondaryItem, {
|
||||||
maxWidth: Math.round(dom.getScreenWidth() * 0.20),
|
maxWidth: osdPoster.clientWidth * 2,
|
||||||
type: "Primary"
|
type: "Primary"
|
||||||
})), imgUrl) {
|
})), imgUrl) {
|
||||||
return void (osdPoster.innerHTML = '<img src="' + imgUrl + '" />');
|
return void (osdPoster.innerHTML = '<img src="' + imgUrl + '" />');
|
||||||
|
|
|
@ -88,7 +88,7 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light",
|
||||||
|
|
||||||
if (user.PrimaryImageTag) {
|
if (user.PrimaryImageTag) {
|
||||||
imgUrl = ApiClient.getUserImageUrl(user.Id, {
|
imgUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||||
width: 300 * window.devicePixelRatio,
|
width: 300,
|
||||||
tag: user.PrimaryImageTag,
|
tag: user.PrimaryImageTag,
|
||||||
type: "Primary"
|
type: "Primary"
|
||||||
});
|
});
|
||||||
|
|
|
@ -59,8 +59,8 @@ define(["libraries/apiclient/apiclientcore", "localassetmanager"], function(ApiC
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function ApiClientEx(serverAddress, clientName, applicationVersion, deviceName, deviceId, devicePixelRatio) {
|
function ApiClientEx(serverAddress, clientName, applicationVersion, deviceName, deviceId) {
|
||||||
ApiClient.call(this, serverAddress, clientName, applicationVersion, deviceName, deviceId, devicePixelRatio)
|
ApiClient.call(this, serverAddress, clientName, applicationVersion, deviceName, deviceId)
|
||||||
}
|
}
|
||||||
var localPrefix = "local:",
|
var localPrefix = "local:",
|
||||||
localViewPrefix = "localview:";
|
localViewPrefix = "localview:";
|
||||||
|
|
|
@ -58,7 +58,7 @@ define(["events", "appStorage"], function(events, appStorage) {
|
||||||
return request.data && ("string" == typeof request.data ? fetchRequest.body = request.data : (fetchRequest.body = paramsToString(request.data), contentType = contentType || "application/x-www-form-urlencoded; charset=UTF-8")), contentType && (headers["Content-Type"] = contentType), request.timeout ? fetchWithTimeout(request.url, fetchRequest, request.timeout) : fetch(request.url, fetchRequest)
|
return request.data && ("string" == typeof request.data ? fetchRequest.body = request.data : (fetchRequest.body = paramsToString(request.data), contentType = contentType || "application/x-www-form-urlencoded; charset=UTF-8")), contentType && (headers["Content-Type"] = contentType), request.timeout ? fetchWithTimeout(request.url, fetchRequest, request.timeout) : fetch(request.url, fetchRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ApiClient(serverAddress, appName, appVersion, deviceName, deviceId, devicePixelRatio) {
|
function ApiClient(serverAddress, appName, appVersion, deviceName, deviceId) {
|
||||||
if (!serverAddress) {
|
if (!serverAddress) {
|
||||||
throw new Error("Must supply a serverAddress");
|
throw new Error("Must supply a serverAddress");
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,6 @@ define(["events", "appStorage"], function(events, appStorage) {
|
||||||
this._deviceName = deviceName;
|
this._deviceName = deviceName;
|
||||||
this._appName = appName;
|
this._appName = appName;
|
||||||
this._appVersion = appVersion;
|
this._appVersion = appVersion;
|
||||||
this._devicePixelRatio = devicePixelRatio;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSavedEndpointInfo(instance, info) {
|
function setSavedEndpointInfo(instance, info) {
|
||||||
|
@ -218,7 +217,7 @@ define(["events", "appStorage"], function(events, appStorage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeImageOptions(instance, options) {
|
function normalizeImageOptions(instance, options) {
|
||||||
var ratio = instance._devicePixelRatio || 1;
|
var ratio = window.devicePixelRatio;
|
||||||
ratio && (options.minScale && (ratio = Math.max(options.minScale, ratio)), options.width && (options.width = Math.round(options.width * ratio)), options.height && (options.height = Math.round(options.height * ratio)), options.maxWidth && (options.maxWidth = Math.round(options.maxWidth * ratio)), options.maxHeight && (options.maxHeight = Math.round(options.maxHeight * ratio))), options.quality = options.quality || instance.getDefaultImageQuality(options.type), instance.normalizeImageOptions && instance.normalizeImageOptions(options)
|
ratio && (options.minScale && (ratio = Math.max(options.minScale, ratio)), options.width && (options.width = Math.round(options.width * ratio)), options.height && (options.height = Math.round(options.height * ratio)), options.maxWidth && (options.maxWidth = Math.round(options.maxWidth * ratio)), options.maxHeight && (options.maxHeight = Math.round(options.maxHeight * ratio))), options.quality = options.quality || instance.getDefaultImageQuality(options.type), instance.normalizeImageOptions && instance.normalizeImageOptions(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ define(["events", "apiclient", "appStorage"], function (events, apiClientFactory
|
||||||
Manual: 2
|
Manual: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var ConnectionManager = function (credentialProvider, appName, appVersion, deviceName, deviceId, capabilities, devicePixelRatio) {
|
var ConnectionManager = function (credentialProvider, appName, appVersion, deviceName, deviceId, capabilities) {
|
||||||
|
|
||||||
function onAuthenticated(apiClient, result, options, saveCredentials) {
|
function onAuthenticated(apiClient, result, options, saveCredentials) {
|
||||||
var credentials = credentialProvider.credentials();
|
var credentials = credentialProvider.credentials();
|
||||||
|
@ -540,7 +540,7 @@ define(["events", "apiclient", "appStorage"], function (events, apiClientFactory
|
||||||
var apiClient = self.getApiClient(server.Id);
|
var apiClient = self.getApiClient(server.Id);
|
||||||
|
|
||||||
if (!apiClient) {
|
if (!apiClient) {
|
||||||
apiClient = new apiClientFactory(serverUrl, appName, appVersion, deviceName, deviceId, devicePixelRatio);
|
apiClient = new apiClientFactory(serverUrl, appName, appVersion, deviceName, deviceId);
|
||||||
self._apiClients.push(apiClient);
|
self._apiClients.push(apiClient);
|
||||||
apiClient.serverInfo(server);
|
apiClient.serverInfo(server);
|
||||||
apiClient.onAuthenticated = function (instance, result) {
|
apiClient.onAuthenticated = function (instance, result) {
|
||||||
|
|
|
@ -280,7 +280,7 @@ var AppInfo = {};
|
||||||
|
|
||||||
capabilities.DeviceProfile = deviceProfile;
|
capabilities.DeviceProfile = deviceProfile;
|
||||||
|
|
||||||
var connectionManager = new ConnectionManager(credentialProviderInstance, apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId(), capabilities, window.devicePixelRatio);
|
var connectionManager = new ConnectionManager(credentialProviderInstance, apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId(), capabilities);
|
||||||
|
|
||||||
defineConnectionManager(connectionManager);
|
defineConnectionManager(connectionManager);
|
||||||
bindConnectionManagerEvents(connectionManager, events, userSettings);
|
bindConnectionManagerEvents(connectionManager, events, userSettings);
|
||||||
|
@ -291,7 +291,7 @@ var AppInfo = {};
|
||||||
return require(["apiclient"], function (apiClientFactory) {
|
return require(["apiclient"], function (apiClientFactory) {
|
||||||
console.debug("creating ApiClient singleton");
|
console.debug("creating ApiClient singleton");
|
||||||
|
|
||||||
var apiClient = new apiClientFactory(Dashboard.serverAddress(), apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId(), window.devicePixelRatio);
|
var apiClient = new apiClientFactory(Dashboard.serverAddress(), apphost.appName(), apphost.appVersion(), apphost.deviceName(), apphost.deviceId());
|
||||||
|
|
||||||
apiClient.enableAutomaticNetworking = false;
|
apiClient.enableAutomaticNetworking = false;
|
||||||
apiClient.manualAddressOnly = true;
|
apiClient.manualAddressOnly = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue