Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing to Facebook etc doesn't share correct image #18

Closed
Jon007 opened this issue Dec 23, 2016 · 4 comments · Fixed by #20
Closed

Sharing to Facebook etc doesn't share correct image #18

Jon007 opened this issue Dec 23, 2016 · 4 comments · Fixed by #20

Comments

@Jon007
Copy link
Contributor

Jon007 commented Dec 23, 2016

Sharing to Facebook etc doesn't share correct image.
When paging through a picture gallery, the code does not change the page level meta attributes.
This means that facebook gets the original page image (eg the WordPress Featured image) from the meta and not the image the user is trying to share.

To fix this, these types of properties need to be reset:

<meta property="og:image" content="">
<meta property="og:image:width" content="">
<meta property="og:image:height" content="">
<meta name="twitter:image" content="">

This might need to be done on the server, the add-in would need to set the featured image based on the &gid=psgal_280_2&pid=1 query string, since when facebook etc calls the site looking for the image for the post it's probably going for the meta directly without triggering the javascript.

thoughts?

While this doesn't work, the sharing should perhaps be disabled...

@Jon007
Copy link
Contributor Author

Jon007 commented Dec 23, 2016

fix: in wp-content/plugins/photoswipe-masonry/photoswipe-dist/photoswipe-ui-default.min.js
change:
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}'}
to:
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}&picture={{raw_image_url}}'}

Caveats:

  • the &picture= parameter may not be officially supported by Facebook but it works for now
  • this is a change to Photoswipe redistributable, however it would work for all Photoswipe usage including non-Wordpress use, so could be proposed to the author
  • a full Wordpress implementation might add the image to the url being passed to the sharing links, so that the server can detect and change the featured image/meta tags. this appears not to be necessary for now.

@Jon007
Copy link
Contributor Author

Jon007 commented Dec 24, 2016

(this doesn't solve the problem for twitter of course, which doesn't seem to accept a url parameter to override the twitter card, I would just remove the twitter sharing option)

@Jon007
Copy link
Contributor Author

Jon007 commented Dec 31, 2016

further fix, even better is to add the description of the current image rather than just using the description of the page:
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}&picture={{raw_image_url}}&description={{text}}'},

small separate issue, photoswipe isn't trying hard enough to get the description, as I have commented further on thriveweb/photoswipe-masonry#2

@Jon007
Copy link
Contributor Author

Jon007 commented Jan 3, 2017

This should be addressed in Photoswipe source but isn't yet, refer to dimsemenov/PhotoSwipe#749

Jon007 added a commit to Jon007/photoswipe-masonry that referenced this issue Jan 3, 2017
Fixes thriveweb#18 by:
- adding current image url and caption to Facebook sharing link
- hiding twitter link since not fixable via this method
Jon007 added a commit to Jon007/photoswipe-masonry that referenced this issue Jan 3, 2017
Fixes thriveweb#18 by:
- adding current image url and caption to Facebook sharing link
- hiding twitter link since not fixable via this method
applying same to minified and unminified file
Jon007 added a commit to Jon007/photoswipe-masonry that referenced this issue Jan 3, 2017
Fixes thriveweb#18 by adding current image to Facebook link
thriveweb pushed a commit that referenced this issue Jan 3, 2017
Patch 1 Fixes #18 by adding current image to Facebook link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant