Share image on a custom twitter share button
I have experience with facebook feed. I recently switched to using twitter and would like to create a custom share button on my website.
The problem is that I am linking to the photo cartogram tutorial, but the image is not showing,
it works when i use plain text
$('#twitter_share').click(function (e) {
e.preventDefault();
var loc = "<?= base_url(uri_string()); ?>";
var title = "<?= $video->title; ?>";
window.open('http://twitter.com/share?url=' + loc + '&text=' + title + '&', 'twitterwindow', 'height=450, width=550, top='+($(window).height()/2 - 225) +', left='+$(window).width()/2 +', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');
});
but crashing when i share an image and i only need to share one image.
$('#twitter_share').click(function (e) {
e.preventDefault();
var loc = "<?= base_url(uri_string()); ?>";
var title = "<?= $video->title; ?>";
var image = "<?= isset($video->image_url) ? site_url("thumbnail/" . $video->image_url) : site_url("assets/img/cms/video.png"); ?>";
window.open('http://twitter.com/share?card=photo&image=' + image + '&url=' + loc + '&title=' + title + '&', 'twitterwindow', 'height=450, width=550, top='+($(window).height()/2 - 225) +', left='+$(window).width()/2 +', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');
});
any fix for it? Thanks for the help.
Link: https://dev.twitter.com/cards/types/photo
And all I need to do in the feed:
- current url
- name
- Description
- Picture
+3
source to share
No one has answered this question yet
Check out similar questions: