I ended this with Tumblr built a button widget , and then slightly modified JS. Since I wanted to use the Tumblr icon from Font Awesome / Bootstrap, I simply removed the style attributes that JS assigns, and then assigned the corresponding class to the anchor created by JS. Instructions are as follows:
1. Get the code: Choose the style of the random button (it doesn’t matter because you delete the code that sets the background image), set the message type to “photo” and select “Javascript” as the programming language (the last two options can be found in the section "Advanced" accordion). Once you do this, Tumblr will spit out code that you can change.
2. Create a new fragment: Create a new fragment in the theme editor, and then copy and paste the scripts found in steps 1 and 3 of the button builder.
<script src="http://platform.tumblr.com/v1/share.js"></script> <script type="text/javascript"> var tumblr_photo_source = ""; var tumblr_photo_caption = ""; var tumblr_photo_click_thru = ""; </script> <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:20px; height:20px; background:url('http://platform.tumblr.com/v1/share_4.png') top left no-repeat transparent;"); tumblr_button.innerHTML = "Share on Tumblr"; document.getElementById("tumblr_button_abc123").appendChild(tumblr_button); </script>
3. Configure JS: First set the variables. You can then specify a background image or icon for the anchor. As I said, I use the Tumblr icon from Font Awesome, so I just removed all the style attributes, innerHTML, and assigned the class "fa fa-tumblr".
If you want to use a background image, you can simply replace the URL with your image and adjust the height and width properties.
<script src="http://platform.tumblr.com/v1/share.js"></script> <script type="text/javascript"> var tumblr_photo_source = "{{ product.featured_image | product_img_url: "master" }}"; var tumblr_photo_caption = ""; var tumblr_photo_click_thru = "{{ shop.url | append: product.url }}"; </script> <script type="text/javascript"> var tumblr_button = document.createElement("a"); tumblr_button.setAttribute("class", "fa fa-tumblr"); 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"); document.getElementById("tumblr_button_abc123").appendChild(tumblr_button); </script>
4. Include the button and snippet in your HTML: Finally, paste the code below wherever you want your button to appear.
<span id="tumblr_button_abc123"></span>
And add the snippet just before </body> to the theme.liquid file.
{% include 'your-tumblr-script-name' %}