Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 06-10-2010 15:03:43

peter_dyson
Member
Registered: 03-22-2010
Posts: 7

Facebook Share Function

Hi guys,

Is there anyway to get a picture to display on Facebook when you add your website's url to it.

To get it to work you need to add   <link rel="image_src" href="thumbnail_image" / >   to the   <head>   of the document, where "thumbnail_image" is the absolute url reference to the picture you want to display.

I can use php to create the correct  <link>  tag within the body of the text,

<?php //for facebook
print '<link rel="image_src" href="www.jadorelamaison.co.uk/install/' . $imgurl .  '" />';
?>

but when I put this in to the  <head>  of the document it doesn't populate $imgurl with anything.

I assume this is because  $imgurl  isn't defined this early in the code.


Is there any way to get the absolute url of your product image in to the <head> of your document??

Thanks for your help.

Offline

 

#2 06-10-2010 17:37:58

susan2go
Member
Registered: 04-19-2010
Posts: 81

Re: Facebook Share Function

Look in [private-directory]\core\CORE\includes\multitask.php

Offline

 

#3 06-14-2010 15:39:00

peter_dyson
Member
Registered: 03-22-2010
Posts: 7

Re: Facebook Share Function

susan2go wrote:

Look in [private-directory]\core\CORE\includes\multitask.php

Thanks for the reply but what do you mean by "Look in"? I've had a look at the php code, but I'm not sure how this helps.

It's probably gone straight over my head.

Offline

 

#4 06-14-2010 16:39:06

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: Facebook Share Function

Who's page are you trying to place this in, ccp's or facebooks?

John

Offline

 

#5 06-15-2010 10:38:59

susan2go
Member
Registered: 04-19-2010
Posts: 81

Re: Facebook Share Function

peter_dyson wrote:

susan2go wrote:

Look in [private-directory]\core\CORE\includes\multitask.php

Thanks for the reply but what do you mean by "Look in"? I've had a look at the php code, but I'm not sure how this helps.

It's probably gone straight over my head.

That's the place where the link to the .css file and .js files are located.  If you want a rel link in the head that's the place to put it.  You don't need to set it up with php either.

I really don't understand your variable $imgurl.  There is no function defined for that as far as I can tell.  I don't even understand why you need a reference in the head either.  I installed a Twitter link and button the normal way in CCP7. 

Code:

<p><a href="http://www.twitter.com/mycompany" target="_blank"><img src="http://twitter-badges.s3.amazonaws.com/follow_us-c.png" alt="Follow Mycompany on Twitter"/></a><p>

Offline

 

#6 06-15-2010 12:30:22

peter_dyson
Member
Registered: 03-22-2010
Posts: 7

Re: Facebook Share Function

dh783 wrote:

Who's page are you trying to place this in, ccp's or facebooks?

John

I must have not made myself totally clear. My fault.

When you are logged into Facebook and you type a URL onto somebodys wall, Facebook will go to that URL and take an image and a description from that site. This description and image will then be displayed on that person's wall.

Currently when I paste a URL from my site, only a description comes up.

What I want to happen is that when I paste the URL of one of my products, for instance a spotted teapot, on to somebodys wall I want the image of that spotted teapot and the short description of that spotted teapot to appear on that persons wall.

I have looked on Facebook's help section and they say that to get it to work properly everytime you need to add   <link rel="image_src" href="thumbnail_image" / >   to the   <head>   of the document, where "thumbnail_image" is the absolute url reference to the picture you want to display.

susan2go wrote:

I really don't understand your variable $imgurl.

$imgurl is a variable from Store>Store Displays>Product Detail Display>Default Format. It is the variable the is used for the image that is displayed for the product on that page.

Offline

 

#7 06-15-2010 18:09:41

susan2go
Member
Registered: 04-19-2010
Posts: 81

Re: Facebook Share Function

I would try putting  <link rel="image_src" href="thumbnail_image" / >  in multitask.php near the link to the .css file then type the url into facebook.

Offline

 

#8 06-19-2010 06:16:50

peter_dyson
Member
Registered: 03-22-2010
Posts: 7

Re: Facebook Share Function

Thanks again for your reply, but this would mean the same image would appear in Facebook regardless of which url I pasted in.

I need a php tag that will populate the "thumbnail-image" with an absolute image url that is relevant to the page it is describing.

So that when somebody shares the url of a teapot, they get shown a picture of a teapot. And when they share the url of a vintage clock they get shown a picture of a vintage clock, not just a generic photo which would be the same for all pages.

The picture needs to be dynamic.

Offline

 

#9 11-06-2010 16:43:27

v8power
Member
From: California
Registered: 05-12-2004
Posts: 170
Website

Re: Facebook Share Function

Any solution to this?
Share on Facebook will not find an image to make a thumbnail......

Offline

 

#10 11-07-2010 08:59:15

peter_dyson
Member
Registered: 03-22-2010
Posts: 7

Re: Facebook Share Function

I did find a way to do this.

This may be a long way round, but it works.

What you need to do is add some php bits into the head section (which you will find in skin.php in the displays section) to call your variables for the image. These do get called further down in the code in the product detail section but you need them in the head section, it doesn't seem to matter if you call them twice.

You need to add this code into the <head> section

<?php

$ns       = $this->globals('core.namespace');
$eol      = $this->globals('core.eol');
$proddisp = $this->globals('ecom.prod_proddetail');
$xid      = $proddisp['id'];
$id       = $this->xhtml_encode($xid);

$imglist  = $proddisp['imglg'];

if (empty($imglist)) {$imglist = 'ADD GENERIC PHOTO HERE FOR WHEN YOU ARE NOT LINKING A PRODUCT PAGE TO FACEBOOK, IT SHOULD BE KEPT IN THE BASE DIRECTORY FOR YOUR SHOP eg example.jpg';}

$imglist  = $this->make_list($imglist);
$imgwidth = $this->globals('core_settings.ecom.imgsizeprodlg');
$imgtag   = '';

if (empty($imgwidth)) {$imgwidth = ADD YOUR OWN PRODUCT IMAGE WIDTH HERE eg. 50;}

foreach ($imglist as $num => $img) {

     $imgurl   = 'media/ecom/prodlg/' . $img;

     $imgtag   .= '<img src="' . $imgurl . '" ';
     if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';}
     $imgtag  .= 'alt="' . $prodname . '" />';

}
?>

<?php //for facebook
print '<link rel="image_src" href="http://www.jadorelamaison.co.uk/install/'. $imgurl . '" />';
?>

Last edited by peter_dyson (11-07-2010 09:05:25)

Offline

 

#11 06-30-2011 19:48:35

karrasda103
Member
Registered: 06-02-2010
Posts: 44

Re: Facebook Share Function

used the code there. apparently facebook is pulling the image from joomla and not ccp so this didn't work for me as of yet.

Offline

 

#12 06-30-2011 20:41:32

karrasda103
Member
Registered: 06-02-2010
Posts: 44

Re: Facebook Share Function

got it to work. Used the same code and posted it in the joomla skin.php head section instead

Offline

 

#13 07-06-2011 04:27:10

jacekstypowski2020
Member
Registered: 07-06-2011
Posts: 1

Re: Facebook Share Function

Is there way to integrate it as a plugin ?




Offline

 

Board footer