mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Fix refreshing images in browser
This commit is contained in:
parent
3a520405c4
commit
8ade73fa35
4 changed files with 28 additions and 22 deletions
|
@ -501,16 +501,19 @@ $('*').on('click', '.refresh_pms_image', function (e) {
|
||||||
pms_proxy_url = /^url\((['"]?)(.*)\1\)$/.exec(pms_proxy_url);
|
pms_proxy_url = /^url\((['"]?)(.*)\1\)$/.exec(pms_proxy_url);
|
||||||
pms_proxy_url = pms_proxy_url ? pms_proxy_url[2] : ""; // If matched, retrieve url, otherwise ""
|
pms_proxy_url = pms_proxy_url ? pms_proxy_url[2] : ""; // If matched, retrieve url, otherwise ""
|
||||||
|
|
||||||
if (pms_proxy_url.indexOf('pms_image_proxy') == -1) {
|
if (pms_proxy_url.indexOf('pms_image_proxy') === -1) {
|
||||||
console.log('PMS image proxy url not found.');
|
console.log('PMS image proxy url not found.');
|
||||||
} else {
|
} else {
|
||||||
if (pms_proxy_url.indexOf('refresh=true') > -1) {
|
background_div.css('background-image', 'none')
|
||||||
pms_proxy_url = pms_proxy_url.replace("&refresh=true", "");
|
$.ajax({
|
||||||
background_div.css('background-image', 'url(' + pms_proxy_url + ')');
|
url: pms_proxy_url,
|
||||||
background_div.css('background-image', 'url(' + pms_proxy_url + '&refresh=true)');
|
headers: {
|
||||||
} else {
|
'Cache-Control': 'no-cache'
|
||||||
background_div.css('background-image', 'url(' + pms_proxy_url + '&refresh=true)');
|
},
|
||||||
}
|
success: function () {
|
||||||
|
background_div.css('background-image', 'url(' + pms_proxy_url + ')');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2831,8 +2831,9 @@ class PmsConnect(object):
|
||||||
|
|
||||||
if img:
|
if img:
|
||||||
web_img = img.startswith('http')
|
web_img = img.startswith('http')
|
||||||
|
resource_img = img.startswith('/:/resources')
|
||||||
|
|
||||||
if refresh and not web_img:
|
if refresh and not web_img and not resource_img:
|
||||||
img = '{}/{}'.format(img.rstrip('/'), helpers.timestamp())
|
img = '{}/{}'.format(img.rstrip('/'), helpers.timestamp())
|
||||||
|
|
||||||
if web_img:
|
if web_img:
|
||||||
|
|
|
@ -4611,7 +4611,7 @@ class WebInterface(object):
|
||||||
""" See real_pms_image_proxy docs string"""
|
""" See real_pms_image_proxy docs string"""
|
||||||
|
|
||||||
refresh = False
|
refresh = False
|
||||||
if kwargs.get('refresh'):
|
if kwargs.get('refresh') or 'no-cache' in cherrypy.request.headers.get('Cache-Control', ''):
|
||||||
refresh = False if get_session_user_id() else True
|
refresh = False if get_session_user_id() else True
|
||||||
|
|
||||||
kwargs['refresh'] = refresh
|
kwargs['refresh'] = refresh
|
||||||
|
@ -4645,6 +4645,8 @@ class WebInterface(object):
|
||||||
None
|
None
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
cherrypy.response.headers['Cache-Control'] = 'max-age=2592000' # 30 days
|
||||||
|
|
||||||
if isinstance(img, str) and img.startswith('interfaces/default/images'):
|
if isinstance(img, str) and img.startswith('interfaces/default/images'):
|
||||||
fp = os.path.join(plexpy.PROG_DIR, 'data', img)
|
fp = os.path.join(plexpy.PROG_DIR, 'data', img)
|
||||||
return serve_file(path=fp, content_type='image/png')
|
return serve_file(path=fp, content_type='image/png')
|
||||||
|
@ -4727,6 +4729,7 @@ class WebInterface(object):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warn("Failed to get image %s, falling back to %s." % (img, fallback))
|
logger.warn("Failed to get image %s, falling back to %s." % (img, fallback))
|
||||||
|
cherrypy.response.headers['Cache-Control'] = "max-age=0,no-cache,no-store"
|
||||||
if fallback in common.DEFAULT_IMAGES:
|
if fallback in common.DEFAULT_IMAGES:
|
||||||
fbi = common.DEFAULT_IMAGES[fallback]
|
fbi = common.DEFAULT_IMAGES[fallback]
|
||||||
fp = os.path.join(plexpy.PROG_DIR, 'data', fbi)
|
fp = os.path.join(plexpy.PROG_DIR, 'data', fbi)
|
||||||
|
|
|
@ -225,20 +225,19 @@ def initialize(options):
|
||||||
'tools.sessions.on': False,
|
'tools.sessions.on': False,
|
||||||
'tools.auth.on': False
|
'tools.auth.on': False
|
||||||
},
|
},
|
||||||
#'/pms_image_proxy': {
|
'/pms_image_proxy': {
|
||||||
# 'tools.staticdir.on': True,
|
'tools.caching.on': True,
|
||||||
# 'tools.staticdir.dir': os.path.join(plexpy.CONFIG.CACHE_DIR, 'images'),
|
'tools.caching.force': True,
|
||||||
# 'tools.caching.on': True,
|
'tools.caching.delay': 0,
|
||||||
# 'tools.caching.force': True,
|
'tools.expires.on': True,
|
||||||
# 'tools.caching.delay': 0,
|
'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
|
||||||
# 'tools.expires.on': True,
|
'tools.auth.on': False,
|
||||||
# 'tools.expires.secs': 60 * 60 * 24 * 30, # 30 days
|
'tools.sessions.on': False
|
||||||
# 'tools.auth.on': False,
|
},
|
||||||
# 'tools.sessions.on': False
|
|
||||||
#},
|
|
||||||
'/favicon.ico': {
|
'/favicon.ico': {
|
||||||
'tools.staticfile.on': True,
|
'tools.staticfile.on': True,
|
||||||
'tools.staticfile.filename': os.path.abspath(os.path.join(plexpy.PROG_DIR, 'data/interfaces/default/images/favicon/favicon.ico')),
|
'tools.staticfile.filename': os.path.abspath(os.path.join(
|
||||||
|
plexpy.PROG_DIR, 'data/interfaces/default/images/favicon/favicon.ico')),
|
||||||
'tools.caching.on': True,
|
'tools.caching.on': True,
|
||||||
'tools.caching.force': True,
|
'tools.caching.force': True,
|
||||||
'tools.caching.delay': 0,
|
'tools.caching.delay': 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue