Pergunta

In my app, users can drag and drop different image files to create a collage. However, I want to make it possible for users to be able to Pin the entire completed collage onto Pinterest. Currently, the 'Pin It' API only seems to recognize the individual images (and sometimes it doesn't even recognize that). What's the best way to tackle this problem?

Is there a screen capture gem that anyone would recommend that I could use to create a separate link to the user's collage, which the user could then pin?

Thanks in advance!

Foi útil?

Solução

Well, I ended up using IMGkit with wkhtmltoimage https://github.com/csquared/IMGKit.

In my controller, I used something that looked like this:

kit = IMGKit.new("myurl") 
IMGKit.new('<meta name="imgkit-height" content="990"><meta name="imgkit-width" content="635">')
send_data(kit.to_png, :type => "html", :disposition => 'inline' )  

And because the gem uses send_data, I captured the image with some code like this:

image_tag(url_for(:action => :garden_image), :size => 3)

And then some CSS for the image_tag:

<div id ="image_element" style="display:none;">

Alternately, if you don't perhaps like using the display:none in the CSS, I considered using a pop-up button labeled "Pinterest Friendly View" for accomplishing the same thing. You can also crop the image IMGKit captures with meta tags, but I struggled making that work. You can hit up the author of the gem for help on that.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top