I'm trying to display all the images in a page and when clicked on each image it has to enlarge, so for that, I have used fancybox. But the code is not working. I'm new to rails, could anyone help me out to solve this issue?
_images.html.erb code:
<div class="center" id="images" style="padding:50px 50px 50px 50px;">
<table>
<% @images.each_slice(4) do |images| %>
<tr>
<% images.each do |images| %>
<td style="padding-right:10px;padding-bottom:10px;">
<%= link_to image_tag images, id: '#images', class: "fancybox"
,:size => "300x300" %><br />
</td>
<% end %>
</div>
</tr>
<% end %>
</table>
</div>
/* fancybox code */
$(document).ready(function() {
$("a.fancybox").fancybox();
});
Try like this as it mentioned in doc here
also make sure images
(so if you are using paperclip carrierwave then it should be image_url
) variable is image link, and on link_to
it expects bigger image than with image_tag
<% images.each do |image| %>
<%= link_to image_url, class: 'fancybox' do%>
<%= image_tag image_url(:thumb), id: 'images', :size => "300x300"%>
<%end%>
<%end%>