-
AuthorPosts
-
ozzymanson2 Friend
ozzymanson2
- Join date:
- September 2012
- Posts:
- 75
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 6
- Thanked:
- 4 times in 1 posts
December 28, 2012 at 5:53 am #183472i have problems with og:image generation in com_content. as you can see it’s gave me a bad path to the images from facebook
<meta property=”og:image” content=”http://ekb.rhrn.co/http://photos-b.ak.fbcdn.net/hphotos-ak-ash3/150692_432801456785249_1355715734_s.jpg”/>
also i have the same issue in K2, ‘cos K2 doesn’t generate og:image at all
ozzymanson2 Friendozzymanson2
- Join date:
- September 2012
- Posts:
- 75
- Downloads:
- 0
- Uploads:
- 2
- Thanks:
- 6
- Thanked:
- 4 times in 1 posts
December 28, 2012 at 6:10 am #477728i’ve add this code to K2
<?php
$fbog =& JFactory::getDocument();
$opengraph_meta = ‘
<meta property=”og:title” content=”‘.$this->item->title.'”/>
<meta property=”og:type” content=”blog”/>
<meta property=”og:url” content=”‘.JURI::getInstance()->toString().'”/>
<meta property=”og:site_name” content=”YOUR_SITE_NAME”/>
<meta property=”fb:admins” content=”INSERT_YOUR_FACEBOOK_ID”/>
‘;
if (!empty($this->item->image)) {
$opengraph_meta .= ‘<meta property=”og:image” content=”‘.JURI::base().”.$this->item->image.'”/>’;
}
else {
$opengraph_meta .= ‘<meta property=”og:image” content=”http://imagedoomain.com/no-image.jpg”/>’;
}
$fbog->addCustomTag( $opengraph_meta );
?>but it gaves me the same path
<meta property=”og:image” content=”http://ekb.rhrn.co/http://distilleryimage1.s3.amazonaws.com/c59ff1da504911e293ab22000a9f1919_7.jpg”/>
how can i solve it?
arucardx Friendarucardx
- Join date:
- July 2010
- Posts:
- 346
- Downloads:
- 0
- Uploads:
- 10
- Thanks:
- 21
- Thanked:
- 138 times in 104 posts
December 28, 2012 at 7:22 am #477740o.O is that my code from the K2 forum? Well if its outputting your domain on top of the external url, then I guess what you can simply do is to remove JURI::base. It shouldn’t cause any problem if all your images are from external sources. Otherwise, we will need to use strpos and attempt to create another if rule for strings that already contains http://.
None the less, the code without juri::base should look like this.
<?php
$fbog =& JFactory::getDocument();
$opengraph_meta = '
<meta property="og:title" content="'.$this->item->title.'"/>
<meta property="og:type" content="blog"/>
<meta property="og:url" content="'.JURI::getInstance()->toString().'"/>
<meta property="og:site_name" content="YOUR_SITE_NAME"/>
<meta property="fb:admins" content="INSERT_YOUR_FACEBOOK_ID"/>
';
if (!empty($this->item->image)) {
$opengraph_meta .= '<meta property="og:image" content="'.$this->item->image.'"/>';
}
else {
$opengraph_meta .= '<meta property="og:image" content="http://imagedoomain.com/no-image.jpg"/>';
}
$fbog->addCustomTag( $opengraph_meta );
?>
Didn’t test it, but let me know if there’s a syntax error or if the output is still wrong.
-
AuthorPosts
This topic contains 3 replies, has 2 voices, and was last updated by arucardx 12 years ago.
We moved to new unified forum. Please post all new support queries in our New Forum