Skip to content

Commit

Permalink
Refactored image_fu helper to only use geometry when not nil.
Browse files Browse the repository at this point in the history
Conflicts:
	core/app/helpers/refinery/image_helper.rb
  • Loading branch information
parndt committed Dec 23, 2014
1 parent 0f87a2f commit 065c5f4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions core/app/helpers/refinery/image_helper.rb
Expand Up @@ -20,15 +20,16 @@ def content_fu(content, thumbnail)
# Say for example that we had a @model.image (@model having a belongs_to :image relationship)
# and we wanted to display a thumbnail cropped to 200x200 then we can use image_fu like this:
# <%= image_fu @model.image, '200x200' %> or with no thumbnail: <%= image_fu @model.image %>
def image_fu(image, geometry = nil, options={})
if image.present?
dimensions = (image.thumbnail_dimensions(geometry) rescue {})
def image_fu(image, geometry = nil, options = {})
return nil if image.blank?

image_tag(image.thumbnail(:geometry => geometry,
:strip => options[:strip]).url, {
:alt => image.respond_to?(:title) ? image.title : image.image_name,
}.merge(dimensions).merge(options))
end
thumbnail_args = options.slice(:strip)
thumbnail_args[:geometry] = geometry if geometry

image_tag_args = (image.thumbnail_dimensions(geometry) rescue {})
image_tag_args[:alt] = image.respond_to?(:title) ? image.title : image.image_name

image_tag(image.thumbnail(thumbnail_args).url, image_tag_args.merge(options))
end
end
end

0 comments on commit 065c5f4

Please sign in to comment.