Skip to content

Commit

Permalink
function for extracting Instagram ID
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGermuska committed Jan 9, 2014
1 parent e190a06 commit 29544e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions source/js/Core/Media/VMM.ExternalAPI.js
Expand Up @@ -1230,6 +1230,16 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {

isInstagramUrl: function(url) {
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;
}

}
},

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

0 comments on commit 29544e2

Please sign in to comment.