Jump to content

Tumblr's 'Share on Tumblr' button only for pages, not posts.


Beldonga

Recommended Posts

Hi, Tumblr's current 'Share on Tumblr' button

 http://www.tumblr.com/buttons 

is made to share PAGES, not posts. I want visitors of my wordpress blog to be able to share pictures. Tumblr is, after all, a picture blog. A post to tumblr should therefor be a picture post, using a posts 'Feature image' as the picture. This post should include the source, title, click-through, and the text from within the post (the later will only be visible on tumblr if you choose to view the whole post). Anyone out there skilled enough to modify this? A friend of mine told me to put the ID Number from the object in html elements ID-field. But I have no idea what that means, or how to do it. Following is the code I use so far. It does what I want, but the click-through and title does not work. <!--Add this code to your page right before the </body> tag. -->(I've been putting this in the index.php after the </body> tag).<script src="http://platform.tumblr.com/v1/share.js"></script> <!-- Put this tag wherever you want your button to appear -->(I've been putting this inside the posts).<span id="tumblr_button_abc123"></span> <!-- Set these variables wherever convenient -->(I've been putting this inside the posts).<script type="text/javascript"> var tumblr_photo_source = "The 'Feature Image'"; var tumblr_photo_caption = "The post title"; var tumblr_photo_click_thru = "The post URL";</script> <!-- Put this code at the bottom of your page -->(I've been putting this inside the posts)<script type="text/javascript"> var tumblr_button = document.createElement("a"); tumblr_button.setAttribute("href", "http://www.tumblr.com/share/photo?source=" + encodeURIComponent(tumblr_photo_source) + "&caption=" + encodeURIComponent(tumblr_photo_caption) + "&clickthru=" + encodeURIComponent(tumblr_photo_click_thru)); tumblr_button.setAttribute("title", "Share on Tumblr"); tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:129px; height:20px; background:url('http://platform.tumblr.com/v1/share_3.png') top left no-repeat transparent;"); tumblr_button.innerHTML = "Share on Tumblr"; document.getElementById("tumblr_button_abc123").appendChild(tumblr_button);</script>

Edited by Beldonga
Link to comment
Share on other sites

That is the code given by Tumblr, so if it's not sending those values then you must not be setting them correctly. Do you have an example of this online? You'll probably need to use PHP to fill out the Javascript variables with the correct values, or else you would need some Javascript code to find the various elements on the page and find that information. That code as given is only going to work for a single button on the page, if you have multiple buttons then more is required.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...