create function to get portal image URL from details - and perform any necessary default URL replacement and https conversion
This commit is contained in:
@ -44,7 +44,7 @@ window.renderPortalDetails = function(guid) {
|
||||
var resoDetails = '<table id="resodetails">' + getResonatorDetails(d) + '</table>';
|
||||
|
||||
setPortalIndicators(d);
|
||||
var img = d.imageByUrl.imageUrl;
|
||||
var img = getPortalImageUrl(d);
|
||||
var lat = d.locationE6.latE6/1E6;
|
||||
var lng = d.locationE6.lngE6/1E6;
|
||||
var perma = '/intel?ll='+lat+','+lng+'&z=17&pll='+lat+','+lng;
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
// PORTAL DETAILS TOOLS //////////////////////////////////////////////
|
||||
// hand any of these functions the details-hash of a portal, and they
|
||||
// will return useful, but raw data.
|
||||
@ -190,3 +188,20 @@ window.potentialPortalLevel = function(d) {
|
||||
}
|
||||
return(potential_level);
|
||||
}
|
||||
|
||||
|
||||
window.getPortalImageUrl = function(d) {
|
||||
if (d.imageByUrl && d.imageByUrl.imageUrl) {
|
||||
url = d.imageByUrl.imageUrl;
|
||||
|
||||
if (window.location.protocol === 'https:') {
|
||||
url = url.indexOf('www.panoramio.com') !== -1
|
||||
? url.replace(/^http:\/\/www/, 'https://ssl').replace('small', 'medium')
|
||||
: url.replace(/^http:\/\//, '//');
|
||||
}
|
||||
return url;
|
||||
} else {
|
||||
return DEFAULT_PORTAL_IMG;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user