Problems with Facebook sharing button and Ajax upload

Luculentus

New Member
Hello from Norway!
I have a customer website that wants to be able to share from their page to Facebook. I have installed the plugin, and it works almost right, exept from the picture that should show when sharing.
I found on the forum that there was an issue with picture URL and sharing if you use Ajax to upload.
Unfortunately my customers website uses Ajax, so the URL in the Facebook share code is showing a lot of gurba, and not the right URL for the actual picture on the page.
I din not find any solution on this issue, how to get the right URL. I can not change the use of Ajax, because, if what you say in the wiki is right, all the links to pictures already uploaded will be changed. That means thousands of pictures related to articles on the website will be gone! And that is days of work uploading all pictures from scratch.... :-(

Any help on this? Any code that will change the ajax url?

Best regards,
Grethe Bjørnæs
Luculentus as
 
Hello,
What are you trying to share? list page or details page
I am using some code in a details view template to specify the image I want to share on facebook or twitter or any social media
 
... all the links to pictures already uploaded will be changed. That means thousands of pictures related to articles on the website will be gone! And that is days of work uploading all pictures from scratch.... :-(
That's not correct. Facebook, Twitter & Co are caching images of shared posts, so they'll stay on no matter what happens to their original image URLs. (Actually, they'd stay the same even if you changed the image on the web page... you'd have to update it in e.g. Facebook if you needed to.)

I am using some code in a details view template to specify the image I want to share on facebook or twitter or any social media
Ditto here.
 
This is the code I am using for detecting the title and description and image that will be sharing on social media
put it in details view template
Code:
$blog=$this->groups['blog'];//blog : the name of group
$blog2=$blog->elements;
$titleraw=$blog2['title']->element_raw; //title : the name of field element
$description=$blog2['description']->element;//description : the name of text area element
$des=Strip_tags($description);
$des2=  implode(' ', array_slice(explode(' ', $des), 0, 25));
$imageraw=$blog2['image']->element_raw;//image : the name of file upload element
$imageraw1 = substr($imageraw, 1);


if (isset($imageraw)){
  $baseURL= JURI::base(); //Gets the base URL
$src = $baseURL.$imageraw1; //Combines the base with the image URL.
  $mydoc = JFactory::getDocument();
  $mydoc->setMetadata('og:image',$src, 'property');
  $mydoc->setMetadata('og:image:type',"image/png", 'property');
  $mydoc->setMetadata('og:image:width',"400", 'property');
  $mydoc->setMetadata('og:image:height',"400", 'property');
// var_dump($src);exit;
}

if (isset($description)){
  $mydoc = JFactory::getDocument();
  $mydoc->setDescription($des2);
}

if (isset($titleraw)){
  $mydoc = JFactory::getDocument();
  $mydoc->setTitle($titleraw);
}
 
Hello,
What are you trying to share? list page or details page
I am using some code in a details view template to specify the image I want to share on facebook or twitter or any social media
It is the fabrik code that is the issue. When I use code made for Facebook, FB can not get the URL for the picture because the Ajax used is making a lobg string with all variables from the databse. I can try to get this code to show you. But I found a discussion in this Forum, where one of the "brains" here said that Ajax was a problem regarding sharing on Facebook. But there was no solution mentioned.
 
This is the code I am using for detecting the title and description and image that will be sharing on social media
put it in details view template
Code:
$blog=$this->groups['blog'];//blog : the name of group
$blog2=$blog->elements;
$titleraw=$blog2['title']->element_raw; //title : the name of field element
$description=$blog2['description']->element;//description : the name of text area element
$des=Strip_tags($description);
$des2=  implode(' ', array_slice(explode(' ', $des), 0, 25));
$imageraw=$blog2['image']->element_raw;//image : the name of file upload element
$imageraw1 = substr($imageraw, 1);


if (isset($imageraw)){
  $baseURL= JURI::base(); //Gets the base URL
$src = $baseURL.$imageraw1; //Combines the base with the image URL.
  $mydoc = JFactory::getDocument();
  $mydoc->setMetadata('og:image',$src, 'property');
  $mydoc->setMetadata('og:image:type',"image/png", 'property');
  $mydoc->setMetadata('og:image:width',"400", 'property');
  $mydoc->setMetadata('og:image:height',"400", 'property');
// var_dump($src);exit;
}

if (isset($description)){
  $mydoc = JFactory::getDocument();
  $mydoc->setDescription($des2);
}

if (isset($titleraw)){
  $mydoc = JFactory::getDocument();
  $mydoc->setTitle($titleraw);
}
I will try this. But I already tried some code without luck, because of the use of Ajax to upload pictures in articles. Tnx for trying to help! :)
 
It is the fabrik code that is the issue. When I use code made for Facebook, FB can not get the URL for the picture because the Ajax used is making a lobg string with all variables from the databse. I can try to get this code to show you. But I found a discussion in this Forum, where one of the "brains" here said that Ajax was a problem regarding sharing on Facebook. But there was no solution mentioned.
 

Attachments

  • facebook_share.png
    facebook_share.png
    372.9 KB · Views: 84
  • Facebook_share_2.png
    Facebook_share_2.png
    31.3 KB · Views: 75
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top