Skip to content

Commit

Permalink
Merge pull request #53 from mejackreed/twitter-cart
Browse files Browse the repository at this point in the history
add twitter card md
  • Loading branch information
mejackreed authored Oct 27, 2016
2 parents a6128f6 + 4c9e370 commit a380da7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion examples/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
var map;
var layer;

map = L.map('map', {
center: [0, 0],
crs: L.CRS.Simple,
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#!:.?+=&%@!\-\/]))?$/;

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') + '">'
);
});

0 comments on commit a380da7

Please sign in to comment.