开发者

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

开发者 https://www.devze.com 2023-03-21 11:31 出处:网络
I am using paperclip to upload and display images in my Rails application. <% @submission.images.each do | image | %>

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 %&开发者_C百科gt;

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.


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'] %>
0

精彩评论

暂无评论...
验证码 换一张
取 消