Linking to social network sites

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
nealk
Regular
Posts: 26
Joined: Sun Sep 20, 2009 1:09 am

Linking to social network sites

Post by nealk »

Hi all,

I'm trying to give my blog entries links so people can easily post the entries to Facebook, Twitter, etc. I'm doing this in my entries.tpl file, inside the {foreach $entries...} loop.

The good news: I got Twitter, Facebook, and Google+ to work.
The bad news: I cannot seem to figure out Pinterest. I'm hoping someone can help.

For Twitter, they just want the URL. So I use:
<img title='Twitter' onclick='javascript:window.open("https://twitter.com/share?url={$entry.r ... status=yes")' src='smimg/twitter.png'>

For Facebook and Google: First install and active the Facebook plugin at https://github.com/s9y/additional_plugi ... t_facebook. This generates <meta property="og:..." /> fields in the header. Then use:
<img title='Facebook' onclick='javascript:window.open("http://www.facebook.com/sharer.php?u={$ ... status=yes")' src='smimg/facebook.png'>
<img title='Google+' onclick='javascript:window.open("https://plus.google.com/share?url={$ent ... status=yes")' src='smimg/google.png'>

(BTW, my social media images in smimg/ are just small icons for each service.)

The problem is with Pinterest...
<img title='Pinterest' onclick='javascript:window.open("http://www.pinterest.com/pin/create/but ... status=yes")' src='smimg/pinterest.png'>

With Pinterest, they need a url (got it), description (got it), and a picture (media=url). I don't know how to extract the first picture's URL from the blog entry. Does anyone know how to do this?
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Linking to social network sites

Post by Timbalu »

Hi

You could try to write your own modifier to regex the entry content for an image, like peggylon demonstrated here http://board.s9y.org/viewtopic.php?f=2&t=19177 (third post).

Or maybe just use a dummy image, always available.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply