Permalink
Browse files

Delete first image from thumnails to avoid duplication, but leave it …

…in lightbox gallery.
  • Loading branch information...
1 parent 645f6e1 commit 2d5010ff936ec310c30d104a09e472e48ff0ac90 @romul committed Aug 17, 2009
@@ -0,0 +1,11 @@
+module ProductImageHelper
+ def link_to_main_product_image(product)
+ large_image_url = product.images.empty? ? "noimage/product.jpg" :
+ product.images.first.attachment.url(:large)
+ link_to product_image(product), large_image_url, :title => product.name
+ end
+
+ def link_to_image(image, title='')
+ link_to(image_tag(image.url(:mini)), image.url(:large), :title => title)
+ end
+end
@@ -0,0 +1,5 @@
+<% if image %>
+ <%= link_to_image(image.attachment, @product.name) %>
+<% else %>
+ <%= link_to_main_product_image(@product) %>
+<% end %>
@@ -5,17 +5,20 @@
<% end -%>
<script type="text/javascript">
$(function() {
- $('#gallery a').lightBox();
+ $('#product-images a').lightBox();
});
</script>
<div id="gallery">
- <ul>
- <% product.images.each do |i| -%>
- <li>
- <%= link_to(image_tag(i.attachment.url(:mini)), i.attachment.url(:large), :title => product.name) %>
- </li>
- <% end -%>
- </ul>
+ <ul>
+ <% is_first = true
+ product.images.each do |i|
+ if is_first
+ is_first = false
+ next
+ end -%>
+ <li><%= link_to_image(i.attachment, product.name) %></li>
+ <% end -%>
+ </ul>
</div>
<% end %>
@@ -4,5 +4,8 @@ class ProductLightboxExtension < Spree::Extension
url "http://spreehq.org"
def activate
# admin.tabs.add "Product Lightbox", "/admin/product_lightbox", :after => "Layouts", :visibility => [:all]
+ Spree::BaseController.class_eval do
+ helper ProductImageHelper
+ end
end
end

0 comments on commit 2d5010f

Please sign in to comment.