Commit 899539f3601bf92d793b01c6dc0010d1630e5b03
Committed by
Daniela Feitosa
1 parent
071c3d79
Exists in
master
and in
29 other branches
Fixing default image method
Showing
5 changed files
with
13 additions
and
5 deletions
Show diff stats
app/helpers/catalog_helper.rb
@@ -8,7 +8,7 @@ include ManageProductsHelper | @@ -8,7 +8,7 @@ include ManageProductsHelper | ||
8 | products.each { |product| | 8 | products.each { |product| |
9 | extra_content = @plugins.map(:catalog_item_extras, product).collect { |content| instance_eval(&content) } | 9 | extra_content = @plugins.map(:catalog_item_extras, product).collect { |content| instance_eval(&content) } |
10 | data << content_tag('li', | 10 | data << content_tag('li', |
11 | - link_to_product(product, :class => 'product-pic', :style => 'background-image:url(%s)' % ( product.image ? product.image.public_filename(:portrait) : '/images/icons-app/product-default-pic-portrait.png' )) + | 11 | + link_to_product(product, :class => 'product-pic', :style => 'background-image:url(%s)' % product.default_image(:portrait) ) + |
12 | content_tag('h3', link_to_product(product)) + | 12 | content_tag('h3', link_to_product(product)) + |
13 | content_tag('ul', | 13 | content_tag('ul', |
14 | (product.price ? content_tag('li', _('Price: %s') % ( "%.2f" % product.price), :class => 'product_price') : '') + | 14 | (product.price ? content_tag('li', _('Price: %s') % ( "%.2f" % product.price), :class => 'product_price') : '') + |
app/models/product.rb
@@ -68,7 +68,7 @@ class Product < ActiveRecord::Base | @@ -68,7 +68,7 @@ class Product < ActiveRecord::Base | ||
68 | end | 68 | end |
69 | 69 | ||
70 | def default_image(size='thumb') | 70 | def default_image(size='thumb') |
71 | - '/images/icons-app/product-default-pic-%s.png' % size | 71 | + image ? image.public_filename(size) : '/images/icons-app/product-default-pic-%s.png' % size |
72 | end | 72 | end |
73 | 73 | ||
74 | def category_full_name | 74 | def category_full_name |
app/models/products_block.rb
@@ -20,7 +20,15 @@ class ProductsBlock < Block | @@ -20,7 +20,15 @@ class ProductsBlock < Block | ||
20 | block_title(title) + | 20 | block_title(title) + |
21 | content_tag( | 21 | content_tag( |
22 | 'ul', | 22 | 'ul', |
23 | - products.map {|product| content_tag('li', link_to(product.name, product.url, :style => 'background-image:url(%s)' % ( product.image ? product.image.public_filename(:minor) : product.default_image('minor'))), :class => 'product' )} | 23 | + products.map {|product| |
24 | + content_tag('li', | ||
25 | + link_to( product.name, | ||
26 | + product.url, | ||
27 | + :style => 'background-image:url(%s)' % product.default_image('minor') | ||
28 | + ), | ||
29 | + :class => 'product' | ||
30 | + ) | ||
31 | + } | ||
24 | ) | 32 | ) |
25 | end | 33 | end |
26 | 34 |
app/views/manage_products/_display_image.rhtml
1 | <div id='display-product-image'> | 1 | <div id='display-product-image'> |
2 | - <%= image_tag (@product.reload.image ? @product.image.public_filename : @product.default_image('thumb')), :class => 'product-pic' %> | 2 | + <%= image_tag (@product.reload.default_image('thumb')), :class => 'product-pic' %> |
3 | </div> | 3 | </div> |
4 | 4 | ||
5 | <%= edit_product_link_to_remote(@product, 'image', _('Change image')) %> | 5 | <%= edit_product_link_to_remote(@product, 'image', _('Change image')) %> |
app/views/manage_products/_edit_image.rhtml
1 | <div id='display-product-image'> | 1 | <div id='display-product-image'> |
2 | - <%= image_tag (@product.reload.image ? @product.image.public_filename : @product.default_image('thumb')), :class => 'product-pic' %> | 2 | + <%= image_tag (@product.reload.default_image('thumb')), :class => 'product-pic' %> |
3 | </div> | 3 | </div> |
4 | 4 | ||
5 | <% form_for(:product, :url => { :controller => 'manage_products', :action => 'edit', :id => @product, :field => 'image' }, :html => { :method => 'post', :id => 'uploadForm', :multipart => true}) do |f| %> | 5 | <% form_for(:product, :url => { :controller => 'manage_products', :action => 'edit', :id => @product, :field => 'image' }, :html => { :method => 'post', :id => 'uploadForm', :multipart => true}) do |f| %> |