Red

BT Social Share does not show the image of properties

17 posts in this topic

hello , I inserted the code bt social share in the file detail.php but it does not show the image of the property, I did a test of the og: and it does not work, solutions? Thank you :)

Share this post


Link to post
Share on other sites

Hi Red.

Maybe, you only use function

$share = plgContentBt_socialshare::socialButtons();

as in document or the plugin's description.

There is other way to use it, that is pass an object as parameter, at here you need to pass property object.

Please try this code in property's detail.php

$share = plgContentBt_socialshare::socialButtons($this->item);

Share this post


Link to post
Share on other sites

Thanks tronghm, now enter OG: name of the image , but then no link does not work , you can see the difference with an article in the attached images

post-193766-0-00357600-1456239196_thumb.

post-193766-0-97371600-1456239202_thumb.

Share this post


Link to post
Share on other sites

Hi there.

Before the BT Social Share code please add right above it this code

$this->item->image = Bt_propertyHelper::getPathImage($this->item->id, 'large', $this->item->image, $this->item->category_id);

I hope it will help you complete solve the problem

:D

Share this post


Link to post
Share on other sites

thanks, now adds the path to the image but not the site link, then social networks never see the correct image. This is the code that I added


<?php
$this->item->image = Bt_propertyHelper::getPathImage($this->item->id, 'large', $this->item->image, $this->item->category_id);
$share = plgContentBt_socialshare::socialButtons($this->item);
JPluginHelper::importPlugin('content');
$share = plgContentBt_socialshare::socialButtons();
echo $share['script']; // Required
echo $share['buttons']; // Social button
echo $share['recommend']; // Recommendation bar
echo $share['comment']; // facebook comment box
?>
[/CODE]

in the attached image the result on google plus

post-193766-0-22307600-1456386865_thumb.

Share this post


Link to post
Share on other sites

Hi.

I'm sorry. I forgot if you use watermark, the function getPathImage will return a html page instead of real image file.

There is two solutions:

1. If your thumbnail image size is big enough about 200px * 200px and you don't apply watermark for thumbnail image, please change 'large' in my code to 'thumbs'

2. Please open file /components/com_bt_property/helpers/helper.php

Find this line

public static function getPathImage($itemId, $imageType, $imageName, $catid) {

change it to

public static function getPathImage($itemId, $imageType, $imageName, $catid, $watermask = true) {

Continue, change this line

$watermask = $params->get('wm-enabled');

to

if($watermask){

$watermask = $params->get('wm-enabled');

}

Then change my code that i gave you to

$this->item->image = Bt_propertyHelper::getPathImage($this->item->id, 'large', $this->item->image, $this->item->category_id, false);

I hope this reply will help you and please ignore spelling mistake with $watermask :D

Share this post


Link to post
Share on other sites

Sorry tronghm, I tried the solution 2 but unfortunately still does not work, the modified files helper.php code, Thanks

<?php
/**
* @package bt_property - BT Property Component
* @version 1.0.0
* @created Aug 2014
* @author BowThemes
* @email support@bowthems.com
* @website http://bowthemes.com
* @support Forum - http://bowthemes.com/forum/
* @copyright Copyright (C) 2014 Bowthemes. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access to this file
defined('_JEXEC') or die;

/**
* Bt_property component helper.
*/
abstract class Bt_propertyHelper {

public static function addSiteScript($maptype = 'google') {

$document = JFactory::getDocument();
$header = $document->getHeadData();
$params = JComponentHelper::getParams("com_bt_property");
self::defineThemePath($params);
$libs = array();
if (!defined('loaded-libs')) {
$libs = $params->get('load-libs', array('jquery'));
$document->addScriptDeclaration('baseUrl = "' . JURI::root(true).'/"');
$document->addScriptDeclaration('assetUrl = "' . JURI::root(true).'/components/com_bt_property/"');
define('loaded-libs',true);
}

if (in_array('jquery', $libs)) {
$loadJquery = true;
foreach ($header['scripts'] as $scriptName => $scriptData) {
if (substr_count($scriptName, '/jquery')) {
$loadJquery = false;
break;
}
}
if ($loadJquery) {
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/jquery.min.js');
}
}

if ($maptype == 'google') {
$document->addScript('//maps.google.com/maps/api/js?sensor=false&libraries=places');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/infobox.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/markerwithlabel_packed.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/markerclusterer_packed.js');
} else if($maptype=='osm') {
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/leaflet.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/leaflet.markercluster.js');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/osm.css');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/leaflet.css');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/MarkerCluster.css');
}

if (in_array('bootstrap.js', $libs)) {
$header = $document->getHeadData();
foreach ($header['scripts'] as $scriptName => $scriptData) {
if (substr_count($scriptName, '/bootstrap.min.js')) {
unset($header['scripts'][$scriptName]);
}
}
$document->setHeadData($header);
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/bootstrap/js/bootstrap.min.js');
$document->addScriptDeclaration("window.addEvent('domready',function() {Element.prototype.hide = function(){};});");
}
if (in_array('bootstrap.css', $libs)) {
$header = $document->getHeadData();
foreach ($header['styleSheets'] as $scriptName => $scriptData) {
if (substr_count($scriptName, '/bootstrap.min.css')) {
unset($header['styleSheets'][$scriptName]);
}
}
$document->setHeadData($header);
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/bootstrap/css/bootstrap.min.css');
}

//owl carousel
if (in_array('owlcarousel', $libs)) {
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/owl.carousel.min.js');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/owl.carousel.css');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/owl.transitions.css');
$params->set('load-owlcarousel', "0");
}
if (in_array('googlefont', $libs)) {
$document->addStyleSheet('//fonts.googleapis.com/css?family=Roboto:300,400,700');
$params->set('load-gfont', "0");
}
if (in_array('awesomefont', $libs)) {
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/fonts/font-awesome.css');
$params->set('load-afont', "0");
}
if (in_array('inputstyle', $libs)) {
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/icheck.min.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/bootstrap-select.min.js');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/bootstrap-select.min.css');
}

$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/jquery.raty.min.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/tmpl.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/jquery.dependClass-0.1.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/draggable-0.1.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/jquery.slider.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/jquery.magnific-popup.min.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/custom-map.js');
$document->addScript(JURI::root(true).'/components/com_bt_property/assets/js/default.js');

$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/jquery.slider.min.css');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/magnific-popup.css');
$document->addStyleSheet(JURI::root(true).'/components/com_bt_property/assets/css/global.css');
$document->addStyleSheet(COM_BT_PROPERTY_THEME_URL . 'css/style.css');
}
public static function defineThemePath($params) {
if (!defined('COM_BT_PROPERTY_THEME_URL')) {
$theme = $params->get('theme', 'default');
$app = JFactory::getApplication();
if (is_dir(JPATH_SITE . '/templates/' . $app->getTemplate() . '/html/com_bt_property/' . $theme)) {
$theme_url = JURI::root(true).'/templates/' . $app->getTemplate() . '/html/com_bt_property/' . $theme . '/';
} elseif (is_dir(JPATH_SITE . '/components/com_bt_property/themes/' . $theme)) {
$theme_url = JURI::root(true).'/components/com_bt_property/themes/' . $theme . '/';
}
if ($theme_url == '') {
return JError::raiseError(500, sprintf(JText::_('COM_BT_PROPERTY_THEME_NOT_FOUND'), $theme));
}
define('COM_BT_PROPERTY_THEME_URL', $theme_url);
}
}

public static function extrafieldHTML($field, $noformat = false) {
$html = '';
switch ($field->type) {
case 'link':
if ($field->value[0]) {
$introlink = $field->value[0];
} else {
$introlink = $field->value[1];
}
$html .= '<a href="' . $field->value[1] . '"target="' . $field->value[2] . '">' . $introlink . '</a>';
break;
case 'image':
$html .= '<img src="' . JURI::root(true).'/' . $field->value . '">';
break;
case 'measurement':
$html .= $field->value . ' ' . $field->default_value[1];
break;
case 'dropdown':
$html .= $field->value[0];
break;
case 'checkboxlist':
$html .= '<ul class="list-unstyled ' . $field->alias . '">';
foreach ($field->default_value as $value) {
$checked = '';
if (in_array($value, $field->value)) {
$html .= '<li>' . $value . '</li>';
}
}
$value .= '</ul>';
break;
default:
$html .= $field->value;
break;
}
if(!$noformat && $field->format){

$html = str_replace('{value}', $html, $field->format);
$html = str_replace('{name}', $field->name, $html);
}
return $html;
}

public static function getRatingPanel($propertyId, $rating_sum, $rating_count, $canRate = true) {
$width = 15;
$height = 15;
$numOfStar = 5;

if ($rating_count == 0)
$rating = 0;
else
$rating = ($rating_sum / $rating_count);

$backgroundWidth = $numOfStar * $width;
$currentWidth = round($rating * $width);

$html = '<div class="btp-rating-container-' . $propertyId . '"><div class="btp-rating-background" style="width: ' . $backgroundWidth . 'px"><div class="btp-rating-current" style="width: '
. $currentWidth . 'px"></div>';

if ($canRate) {
for ($i = $numOfStar; $i > 0; $i--) {
$starWidth = $width * $i;
$html .= '<a onclick="javascript:btShowcase.rate(' . $propertyId . ', ' . $i . ')" href="javascript:void(0);" style="width:' . $starWidth . 'px"></a>';
}
}

$html .= '</div>';

$html .= '<div class="btp-rating-notice">' . sprintf(JText::_('COM_BT_PROPERTY_RATING_TEXT'), $rating, $rating_count) . '</div>';

$html .= '</div>';

return $html;
}
public static function getSocialShare($social_buttons) {
$document = JFactory::getDocument();
//$document->addScriptDeclaration('var switchTo5x=true;');
$document->addScript('http://w.sharethis.com/button/buttons.js');
//$document->addScriptDeclaration('stLight.options({publisher: "349b1eef-d8c5-4c16-81a7-2dcc762843eb"});');
//$document->addScriptDeclaration('stLight.options({publisher: ""});');
if (!is_array($social_buttons)) {
$social_buttons = array($social_buttons);
}
foreach ($social_buttons as $button) {
switch ($button) {
case 1:
//echo "<span class='st_twitter_hcount' displayText='Tweet' st_via='YourTwitterHandleName' st_msg='#YourHashTag and #YourOtherHashTag'></span>";
echo "<span class='st_twitter_hcount' displayText='Tweet'></span> ";

break;
case 2:
echo "<span class='st_plusone_hcount' displayText='Google +1'></span>";
break;
case 3:
echo "<span class='st_linkedin_hcount' displayText='LinkedIn'></span>";
break;
case 4:
echo "<span class='st_email_hcount' displayText='Email'></span>";
break;
case 5:
echo "<span class='st_facebook_hcount' displayText='Facebook'></span>";
break;
case 6:
echo "<span class='st_fbsend_hcount' displayText='Facebook Send'></span>";
break;
case 7:
echo "<span class='st_fblike_hcount' displayText='Facebook Like'></span>";
break;
case 8:
echo "<span class='st_fbrec_hcount' displayText='Facebook Recommend'></span>";
break;
case 9:
echo "<span class='st_pinterest_hcount' displayText='Pinterest'></span>";
break;
}
}
}
public static function getFacebookComment($facebook_app_id, $number_comments, $commmentbox_width) {
$language = JFactory::getLanguage();
$params = JComponentHelper::getParams("com_bt_property");
$locales = $language->getLocale();
$uri = JFactory::getURI();
$locale = str_replace('-', '_', substr($locales[0], 0, 5));
$html = '<fb:comments data-colorscheme="' . $params->get('commmentbox_colorscheme', 'light') . '" href="' . $uri->toString() . '" simple="1" numposts="' . $number_comments . '" width="'
. $commmentbox_width . '"></fb:comments>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: \'' . $facebook_app_id
. '\',
status: true,
cookie: true,
xfbml: true
});
};
(function() {
var e = document.createElement(\'script\');
e.type = \'text/javascript\';
e.src = document.location.protocol + \'//connect.facebook.net/' . $locale
. '/all.js\';
e.async = true;
document.getElementById(\'fb-root\').appendChild(e);
}());
</script>';
if ($commmentbox_width == 'auto') {
$html .= '<style type="text/css">.fb_iframe_widget iframe, .fb_iframe_widget, .fb_iframe_widget span { width:100% !important; }</style>';
}
return $html;
}
public static function getDisqusComment($shortname) {
// Output code
$html = " <div id='disqus_thread'></div>
<script type='text/javascript'>
var disqus_shortname = '" . $shortname
. "';

(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable Javascript to view the <a href='http://disqus.com/?ref_noscript'>comments powered by Disqus.</a></noscript>
<a href='http://disqus.com' class='dsq-brlink'>comments powered by <span class='logo-disqus'>Disqus</span></a>";
return $html;
}
public static function checkComponent($name) {
$path = JPATH_ADMINISTRATOR . '/components/' . $name;
if (is_dir($path)) {
return true;
} else {
return false;
}
}
public static function getPathImage($itemId, $imageType, $imageName, $catid, $watermask = true) {
$params = JComponentHelper::getParams("com_bt_property");
if($watermask){
$watermask = $params->get('wm-enabled');
}
$path = $params->get('images_path', 'images/bt_property');

if (($imageType == 'large' && $params->get('largeimgprocess') == '-1') || ($imageType == 'thumb' && $params->get('thumbimgprocess') == '-1')) {
$imageType = 'original';
}

if ($imageType == 'ssthumb' || (!$params->get('wm-thumb', 1) && $imageType == 'thumb')) {
$watermask = false;
}

if (!in_array('all', $params->get('wm-categories', array('all'))) && !in_array($catid, $params->get('wm-categories', array('all')))) {
$watermask = false;
}
if (!$imageName) {
return COM_BT_PROPERTY_THEME_URL . 'images/no-image.jpg';
}
if (!$watermask) {
$imagePath = JURI::root(true).'/' . $path . '/' . $itemId . '/' . $imageType . '-' . $imageName;
} else {
$imagePath = JRoute::_('index.php?option=com_bt_property&task=property.viewimage&src=' . ($itemId . '|' . $imageName . '|' . $imageType));
}

return $imagePath;
}
public static function showWmImage() {

list($itemId, $imageName, $imageType) = explode('|', (JRequest::getVar('src')));
$params = JComponentHelper::getParams("com_bt_property");
$path = $params->get('images_path', 'images/bt_property');
$source = JPATH_ROOT . '/' . $path . '/' . $itemId . '/' . $imageType . '-' . $imageName;

if ($params->get('wm-enabled') && $imageType != 'ssthumb') {
require_once JPATH_COMPONENT . '/helpers/watermask/watermask.php';
$options = BtWaterMask::getWaterMarkOptions();
$options['padding'] = $params->get('wm-padding', $options['padding']);
$options['font'] = $params->get('wm-font') ? JPATH_COMPONENT . '/helpers/watermask/fonts/' . $params->get('wm-font') . '.ttf' : $options['font'];
$options['text'] = $params->get('wm-text', $options['text']);
$options['image'] = $params->get('wm-image') ? JPATH_ROOT . '/' . $params->get('wm-image') : $options['image'];
$options['type'] = $params->get('wm-type', $options['type']);
$options['fcolor'] = $params->get('wm-fcolor', $options['fcolor']);
$options['fsize'] = $params->get('wm-fsize', $options['fsize']);
$options['bg'] = $params->get('wm-bg', $options['bg']);
$options['bgcolor'] = $params->get('wm-bgcolor', $options['bgcolor']);
$options['factor'] = $params->get('wm-factor', $options['factor']);
$options['position'] = $params->get('wm-position', $options['position']);
$options['opacity'] = $params->get('wm-opacity', $options['opacity']);
$options['rotate'] = $params->get('wm-rotate', $options['rotate']);
BtWaterMask::createWaterMark($source, $options);

} else {
$size = getimagesize($source);
$imagetype = $size[2];
switch ($imagetype) {
case (1):
header('Content-type: image/gif');
$image = imagecreatefromgif($source);
imagegif($image);
break;

case (2):
$image = imagecreatefromjpeg($source);
header('Content-type: image/jpeg');
imagejpeg($image);
break;

case (3):
header('Content-type: image/png');
$image = imagecreatefrompng($source);
imagepng($image);
break;

case (6):
header('Content-type: image/bmp');
$image = imagecreatefrombmp($source);
imagewbmp($image);
break;
}
}
exit;
}

public static function getPrintButton($type, $property_id) {
$print_icon = COM_BT_PROPERTY_THEME_URL . 'images/print-button.gif';
if ($type == 0) {
return '<div class="print_button"><a onclick="window.print();return false;" href="#"><img alt="Print" src="' . $print_icon . '"></a></div>';
} else {
$print_url = JRoute::_('index.php?tmpl=component&option=com_bt_property&view=property&layout=print&id=' . $property_id);
return '<a class="print_button" rel="nofollow" onclick="window.open(this.href,\'win2\',\'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no\'); return false;" title="Print" href="'
. $print_url . '"><img alt="Print" src="' . $print_icon . '"></a>';
}
}
public static function extractUrl($string) {
$regex = "/\<iframe.+src\s*=\s*\"([^\"]*)\"[^\>]*\>/Us";
preg_match($regex, $string, $matches);
$images = (count($matches)) ? $matches : array();
if (count($images)) {
return $images[1];
}
return '';
}
public static function statusTitle($statusid) {
static $status = null;

if ($status === null) {
$query = 'select id,title from #__bt_property_items where published = 1 and type=\'prstatus\'';
$db = JFactory::getDbo();
$db->setQuery($query);
$status = $db->loadObjectList();
}
$neededObjects = array_filter($status, function ($e) use ($statusid) {
return $e->id == $statusid;
});
$neededObject = array_pop($neededObjects);
if ($neededObject)
return JText::_($neededObject->title);
else
return $statusid;
}
public static function getContactFields() {
$params = JComponentHelper::getParams("com_bt_property");
if (Bt_propertyHelper::checkBTSocialConnect()) {
$db = JFactory::getDbo();
$db->setQuery('SELECT * FROM #__bt_user_fields WHERE published = 1' );
$listFields = $db->loadObjectList();
}else{
$listFields = array();
}

$contact = $params->get('agent_contact', array('email', 'phone', 'mobile', 'skype'));
$result = array();

foreach ($listFields as $field) {
foreach ($contact as $item) {
if ($field->alias == $item) {
$result[$item] = $field->name;
}
}
}

if (in_array('email', $contact)) {
$result['email'] = JText::_('JGLOBAL_EMAIL');
}

return $result;

}
public static function formatPrice($price, $priceTime = '') {
$params = JComponentHelper::getParams("com_bt_property");
$priceFormat = JText::_('COM_BT_PROPERTY_PRICE_FORMAT');
if(!trim($priceFormat) || $priceFormat == 'COM_BT_PROPERTY_PRICE_FORMAT'){
$priceFormat = $params->get('price_format', '$ 000');
}
if($price){
$price = number_format($price, $params->get('decimal', 2), $params->get('decimal_symbol', '.'), $params->get('thousands_sep', ','));
return str_replace('000', $price, $priceFormat) . ($priceTime ? '/' . JTEXT::_($priceTime) : '');
}else{
return JText::_('COM_BT_PROPERTY_CALL_FOR_PRICE');
}
}
public static function substring($text, $length = 100, $replacer = '...', $isStrips = true, $stringtags = '') {

if ($isStrips) {
$text = preg_replace('/\<p.*\>/Us', '', $text);
$text = str_replace('</p>', '<br/>', $text);
$text = strip_tags($text, $stringtags);
}

if (function_exists('mb_strlen')) {
if (mb_strlen($text) < $length)
return $text;
$text = mb_substr($text, 0, $length);
} else {
if (strlen($text) < $length)
return $text;
$text = substr($text, 0, $length);
}

return $text . $replacer;
}
public static function getLocationName($id) {
static $locations = null;
if($id){
if (!isset($location[$id])) {
$query = 'select title from #__bt_property_items where published = 1 and id='.$id;
$db = JFactory::getDbo();
$db->setQuery($query);
$location[$id] = $db->loadResult();
}
return JText::_($location[$id]);
}
return '';
}
public static function checkBTSocialConnect(){
$db = JFactory::getDbo();
$db->setQuery('SELECT enabled FROM #__extensions WHERE name = ' . $db->quote('BT_SocialConnect'));
return $db->loadResult();
}
}[/CODE]

Share this post


Link to post
Share on other sites

possible that there is no way to solve this problem? at least someone could suggest how to remove the open graph tags only to the image , so you add it manually in the property description ?

Share this post


Link to post
Share on other sites
On 01/07/2016 at 9:03 AM, Red said:

possible that there is no way to solve this problem? at least someone could suggest how to remove the open graph tags only to the image , so you add it manually in the property description ?

Problem still persists, :(

 

Share this post


Link to post
Share on other sites
4 hours ago, Tam Pham said:

Hello guys,

I'll contact to our developers to solve this problem. I'll come back on next Monday.

Have a nice weekend :)

Best regards,

 
Thank you so much Tam Pham, I could have help for this important issue !? 

thank you

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now