Browse Source

function for extracting Instagram ID

pull/557/head
Joe Germuska 11 years ago
parent
commit
29544e2615
  1. 10
      source/js/Core/Media/VMM.ExternalAPI.js
  2. 4
      source/js/Core/Media/VMM.MediaType.js

10
source/js/Core/Media/VMM.ExternalAPI.js

@ -1230,6 +1230,16 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
isInstagramUrl: function(url) { isInstagramUrl: function(url) {
return url.match("instagr.am/p/") || url.match("instagram.com/p/"); return url.match("instagr.am/p/") || url.match("instagram.com/p/");
},
getInstagramIdFromUrl: function(url) {
try {
return d.split("\/p\/")[1].split("/")[0];
} catch(e) {
trace("Invalid Instagram url: " + url);
return null;
}
} }
}, },

4
source/js/Core/Media/VMM.MediaType.js

@ -92,8 +92,8 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaType == 'undefined') {
} else if (VMM.ExternalAPI.instagram.isInstagramUrl(d)) { } else if (VMM.ExternalAPI.instagram.isInstagramUrl(d)) {
media.type = "instagram"; media.type = "instagram";
media.link = d; media.link = d;
media.id = d.split("\/p\/")[1].split("/")[0]; media.id = VMM.ExternalAPI.instagram.getInstagramIdFromUrl(d)
success = true; success = Boolean(media.id);
} else if (d.match(/jpg|jpeg|png|gif/i) || d.match("staticmap") || d.match("yfrog.com") || d.match("twitpic.com")) { } else if (d.match(/jpg|jpeg|png|gif/i) || d.match("staticmap") || d.match("yfrog.com") || d.match("twitpic.com")) {
media.type = "image"; media.type = "image";
media.id = d; media.id = d;

Loading…
Cancel
Save