Created
March 5, 2013 03:46
-
-
Save MaxLynam/5087848 to your computer and use it in GitHub Desktop.
add FB Open Graph & Twitter Cards META to Joomla
insert into the appropriate com_content files
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
if (isset($images->image_intro) and !empty($images->image_intro)) | |
{ | |
$timage= htmlspecialchars(JURI::root().$images->image_intro); | |
} | |
elseif (isset($images->image_fulltext) and !empty($images->image_fulltext)) | |
{ | |
$timage= htmlspecialchars(JURI::root().$images->image_fulltext); | |
} | |
else | |
{ | |
$timage= 'http://www.example.com/default-image.jpg'; | |
} | |
$doc =& JFactory::getDocument(); | |
$doc->addCustomTag( ' | |
<meta name="twitter:title" content="'.$this->escape($this->item->title).'"> | |
<meta name="twitter:card" content="summary"> | |
<meta name="twitter:site" content="@TwitterUsernameOfWebsite"> | |
<meta name="twitter:creator" content="@TwitterUsernameOfAuthor"> | |
<meta name="twitter:url" content="'.JURI::current().'"> | |
<meta name="twitter:description" content="'.strip_tags($this->item->introtext).'"> | |
<meta name="twitter:image" content="'.$timage.'"> | |
<meta property="og:title" content="'.$this->escape($this->item->title).'"/> | |
<meta property="og:type" content="article"/> | |
<meta property="og:email" content="info@example.com"/> | |
<meta property="og:url" content="'.JURI::current().'"/> | |
<meta property="og:image" content="'.$timage.'"/> | |
<meta property="og:site_name" content="Your Website Name Here"/> | |
<meta property="fb:admins" content="johndoe.3"/> | |
<meta property="og:description" content="'.strip_tags($this->item->introtext).'"/> | |
'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not trialled yet, but looks like a good start ;)