I have some Pinterest code to show a Pin it button on my wordpress posts but it only grabs the post thumbnail. What I want is to grab the first post content image and only grab the thumbnail if there are no images in the post!??
Have tried tons of examples but nothing works.
var pinterestUrl = "http://pinterest.com/pin/create/button/", //pinterest link pageUrl = document.URL, imageUrl = $(selector_for_content_images).find("img").get(0).src, desc = $(selector_for_brief_text_description).text(), complete = [pinterestUrl, "?url=", pageUrl, "&media=", imageUrl, "&description=", desc].join(""); $("a.pin-it-button").attr("href", complete);