New Module: Share (link to Gallery on social media sites)

SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Wed, 2009-10-21 05:48

Hello all,

I have written a simple module for Gallery 2 to provide a Share button to send the link of your Gallery page to social media sites such as Facebook. Right now, Facebook is the only button it has, but it should be easy to extend it to other sites. I implemented it as a block that can be added to your theme anywhere you would like. There is one site-wide setting in the Site Admin page to control whether the button is shown to guests or only when users are logged in.

Anyway, hope you find it useful. It's available through Downloadable Plugins.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2009-10-26 02:58

SiliconFiend,
Thanks for the contribution!
I created a codex page:
http://codex.gallery2.org/Gallery2:Modules:share
feel free to add to or correct as needed.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Mon, 2009-10-26 04:03

Thanks! It's a simple module, so it looks like you've covered everything.

 
beachmonkey

Joined: 2008-05-05
Posts: 31
Posted: Mon, 2010-06-21 06:42

I'm trying to add a myspace and twitter button to this, any ideas? I'm having no luck

www.beachmonkey.com

 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Mon, 2010-06-21 16:41

Myspace: http://wiki.developer.myspace.com/index.php?title=How_to_Add_Share_on_MySpace_to_Your_Site
Twitter: http://twitter.com/goodies, click on the Buttons link. It won't let me past that page because I don't have a Twitter account.

I think you just need to add the appropriate link/button code to ShareBlock.tpl. For Myspace, anyway, the existing metadata is what it is expecting. I may get around to adding it, but don't wait for me...

 
brewster

Joined: 2010-07-12
Posts: 47
Posted: Thu, 2010-08-05 20:53

I installed this module on G2. I run the gallery in an iframe on my site. I had no issues until installing Share. For some reason, it causes iframe's perimeters to be ignored, and G2 display's in front of the website and completely covered it (lays on top of) my website. If I remove Share, everything is back to normal (Gallery 2 stays in the iframe.) Any suggestions on how to resolve this? Thx!
Brewster

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2010-08-05 20:59

To thwart spoofers, many javascript frameworks sidestep iframes altogether with something like:

<script type="text/javascript" language="javascript">
//<![CDATA[
if (top != self) {
    window.top.location.href=location;
}
//]]>
</script>

Your best bet is to dump the iframe altogether and embed your gallery properly.
I have an app for that.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
brewster

Joined: 2010-07-12
Posts: 47
Posted: Fri, 2010-08-06 21:24

Thanks for the suggestion, suprsidr. I tried to embed it into my gallery last night, but after a few hours just gave up. I'm just not familiar enough with programming to understand it, so I didn't really know what I did wrong. Perhaps when I get better versed on this, or have someone watch over my shoulder, I can try it again.

Appreciate your help!
Brewster

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2010-08-06 21:47
 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Mon, 2010-08-09 13:27

I just took a look at the code and there is something similar in the boilerplate code I copied from Facebook, in modules/share/templates/ShareBlockHead.tpl Specifically, it's this:

{* Hide the Facebook bar *}
  if (top.location != location) {ldelim}
    top.location.href = document.location.href;
  {rdelim}

You could try commenting it out (or deleting it) and see if that fixes it.

 
brewster

Joined: 2010-07-12
Posts: 47
Posted: Mon, 2010-08-09 18:18
SiliconFiend wrote:
I just took a look at the code and there is something similar in the boilerplate code I copied from Facebook, in modules/share/templates/ShareBlockHead.tpl Specifically, it's this:

{* Hide the Facebook bar *}
  if (top.location != location) {ldelim}
    top.location.href = document.location.href;
  {rdelim}

You could try commenting it out (or deleting it) and see if that fixes it.

That worked! Thanks for your help.

 
petri
petri's picture

Joined: 2005-12-15
Posts: 253
Posted: Wed, 2010-10-20 01:19

Hi SiliconFiend,

Nice module you did... thank you.

I have a little problem with it : it is not always showing the pictures, either on the pop up window, or on Facebook :

This one does not show any image on the popup neither on Facebook :

http://www.coquille.org/gallery/portfolio/portrait/color/_PDP7033.jpg.html

This one works on the popup but not on Facebook :

http://www.coquille.org/gallery/portfolio/portrait/color/_PDP6857.jpg.html

actually I could publish only one with the photo on Facebook, but it's not working anymore :

http://www.coquille.org/gallery/portfolio/portrait/color/_PDP6718.jpg.html

Do you guys have the same problem ? I know FB is changing it's code so often that we never know if a FB module can last more than a week :-)

Thank you in advance for any kind of answer

-----------------

Gallery URL = http://www.coquille.org/gallery/main.php
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.6 apache2handler
Webserver = Apache/2.0.52 (CentOS)
Database = mysql

 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Wed, 2010-10-20 05:29

Yes, it appears that Facebook changed the API (Bad Facebook!). It still works for me on my site, but it's clearly not what Facebook wants now. On first glance I thought it would be pretty easy, but it's been a while since I worked on any Gallery code and I've forgotten how to do some key things. Fundamentally it's a pretty small change, but it takes some care to get it right.

 
petri
petri's picture

Joined: 2005-12-15
Posts: 253
Posted: Wed, 2010-10-20 10:21

I just realized that RSS graffiti on Facebook had the same problem, some pictures are being published...some not...

it's strange...a FB change for sure...

-----------------

Gallery URL = http://www.coquille.org/gallery/main.php
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.6 apache2handler
Webserver = Apache/2.0.52 (CentOS)
Database = mysql

 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Wed, 2010-10-20 15:50

Something else I just noticed on the Facebook documentation that may cause problems for some photos:

"The og:image is the URL to the image that appears in the Feed story. The thumbnail's width AND height must be at least 50 pixels, and cannot exceed 130x110 pixels. The ratio of both height divided by width and width divided by height (w/h, h/w) cannot exceed 3.0. For example, an image of 126x39 pixels will not be displayed, as the ratio of width divided by height is greater than 3.0 (126/39 = 3.23). Images will be resized proportionally."

I think I've got a handle on the changes. It only involves two files (attached). Would you be willing to test them out and see if it fixes your problem before I publish it more widely? The forum software only lets me upload files with certain extensions, so rename Preloads.txt to Preloads.inc and ShareBlockHead.txt to ShareBlockHead.tpl and then overwrite the corresponding files in the share module (it might be a good idea to make a copy of the original files first).

 
petri
petri's picture

Joined: 2005-12-15
Posts: 253
Posted: Thu, 2010-10-21 07:02

Hi

willing to try but I have connection problems with my website...got to check that out before. :-)

give me some time

-----------------

Gallery URL = http://www.coquille.org/gallery/main.php
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.6 apache2handler
Webserver = Apache/2.0.52 (CentOS)
Database = mysql

 
petri
petri's picture

Joined: 2005-12-15
Posts: 253
Posted: Fri, 2010-10-22 03:34

Hi SiliconFiend,

So I had to delete the share module and totally replace it (permission problems). I replaced the two files as you said and reinstalled the module (which is still on version 1.0.1 on the plugin page) b.

So again the result depends on the picture :

These are the one that were visible on the pop up and on Facebook :

http://www.coquille.org/gallery/portfolio/portrait/color/yuan2.jpg.html
http://www.coquille.org/gallery/portfolio/portrait/color/08.jpg.html
http://www.coquille.org/gallery/portfolio/portrait/color/AAA_1751.jpg.html

This one was only visible on the pop up but did not appear on FB :
http://www.coquille.org/gallery/portfolio/portrait/color/10.jpg.html

These ones did not show anywhere :
http://www.coquille.org/gallery/portfolio/portrait/color/titta8_c.jpg.html
http://www.coquille.org/gallery/portfolio/Landscapes/Color/_PDP7751.jpg.html
http://www.coquille.org/gallery/portfolio/portrait/color/_PDP7033.jpg.html

One more point : when the picture show up everywhere or even on the pop-up, the title of the picture shows up properly on the post on the Facebook.
But when the picture does not show up on the pop and Facebook, the title is the URL of the page : http://www.coquille.org/gallery/portfolio/portrait/color/titta8_c.jpg.html

when you click on the share lick and the popup appears, it looks like the app is looking for the pic, does not find it so just put the URL of the page.

As for the format, I tried different format but nothing seems to be very logical :
not working : http://www.coquille.org/gallery/portfolio/portrait/color/_PDP7033.jpg.html
and working : http://www.coquille.org/gallery/portfolio/portrait/color/AAA_1751.jpg.html

were taken by the same camera and have the same format...

What about you ? is it working for you ?

I work on a mac, if this might change smth...

-----------

Gallery URL = http://www.coquille.org/gallery/main.php
Gallery version = 2.3 core 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.6 apache2handler
Webserver = Apache/2.0.52 (CentOS)
Database = mysql

 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Fri, 2010-10-22 04:27

No, those same ones you mention are not working for me, either (I'm using Firefox on Windows). I saw some complaints on forums that the thumbnails weren't working for other people, too, even when they followed Facebook's guidelines. So, I'm afraid this looks like a Facebook server problem.

 
horizon
horizon's picture

Joined: 2010-11-09
Posts: 2
Posted: Tue, 2010-11-09 22:25

Hi all!
At first excuse for my not good Ehglish..

I have problem with Module: Share (link to Gallery on social media sites).
All works perfectly, but if i klick to Facebook icon there is grammatical mistake in Login window (in Estonian lanquage).
My question: in what folder i can found the file, where i must correct the text and whats the file name?

 
SiliconFiend
SiliconFiend's picture

Joined: 2006-12-27
Posts: 508
Posted: Tue, 2010-11-09 22:41

That sounds like a problem with Facebook, which is out of my control. My module has no translations (that I know of!)

 
horizon
horizon's picture

Joined: 2010-11-09
Posts: 2
Posted: Tue, 2010-11-09 23:29

Hi!
Many thanks for your answer!!