Created
October 29, 2012 12:27
-
-
Save gabrielhpugliese/3973258 to your computer and use it in GitHub Desktop.
Auto Graph App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(){ | |
var $head = jQuery('head'); | |
var img_src = jQuery('img').attr('src'); | |
if (img_src.indexOf('http://') == -1 && img_src.indexOf('https://') == -1) | |
img_src = window.location.protocol + '//' + window.location.hostname + jQuery('img').attr('src'); | |
var ogp_tags = {'title': $head.find('title').text().trim(), | |
'url': window.location.href, | |
'description': '[%description%]' ? '[%description%]' : jQuery('.lead').html(), | |
'image': '[%image%]' ? '[%image%]' : img_src, | |
'type': '[%type%]' ? '[%type%]' : 'website'}; | |
for (i in ogp_tags){ | |
if(ogp_tags.hasOwnProperty(i) && ogp_tags[i] != null) | |
var tag = '<meta property="og:'+ i +'" content="'+ ogp_tags[i] +'" />'; | |
$head.append(tag); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment