diff --git a/examples/index.js b/examples/index.js index df8f083..4360b0c 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,4 +1,5 @@ var map; +var layer; map = L.map('map', { center: [0, 0], @@ -6,7 +7,7 @@ map = L.map('map', { zoom: 0 }); -var url = window.location.search.replace('?url=', '') +var url = window.location.search.replace('?url=', ''); // http://stackoverflow.com/a/18222306 var urlregex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/; @@ -14,3 +15,11 @@ var urlregex = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w# if (urlregex.test(url)) { layer = L.tileLayer.iiif(url, {}).addTo(map); } + +layer.on('load', function() { + $('head').append( + '<meta name="twitter:card" content="summary_large_image">' + + '<meta name="twitter:site" content="@mejackreed">' + + '<meta name="twitter:image" content="' + url.replace('info.json', 'full/' + layer._imageSizes[1].x + ',/0/default.jpg') + '">' + ); +});