tanya
tanya

Reputation: 2985

Paperclip - click on thumbnail to display original image in a popup

I am using paperclip to upload and display images in my Rails application.

<% @submission.images.each do | image | %>

<%= image_tag(image.data.url(:thumb), :alt => '') %>

<% end unless @submission.images.first.new_record? rescue nil %>

The code above displays the thumbnails of the images.

I would like to make the thumbnail a link so that when user clicks on it, a popup is displayed showing the original image.

I tried including a link to the thumbnail as follows:

<%=link_to image_tag(image.data.url(:thumb)), :popup=>['original_image', 'height=700,width=900'] %>

But i have no idea where to put the contents of the popup as image_tag(image.data.url(:original))

Thanks a lot for any suggestion provided.

Upvotes: 3

Views: 6120

Answers (1)

Jeff Paquette
Jeff Paquette

Reputation: 7127

What you have is the thumbnail as a link, but you're missing what you're linking to. Try the following:

<%=link_to image_tag(image.data.url(:thumb)), image.data.url(:original), :popup=>['original_image', 'height=700,width=900'] %>

Upvotes: 11

Related Questions