Skip to content

Instantly share code, notes, and snippets.

@bionicpill
Forked from hungrysquirrel/gist:3306970
Created August 9, 2012 18:42
Show Gist options
  • Save bionicpill/3306975 to your computer and use it in GitHub Desktop.
Save bionicpill/3306975 to your computer and use it in GitHub Desktop.
def default_image_size
320
end
def image_style
"margin: 0;padding: 0;border: 0; max-width: 560px; height: auto;line-height: 100%;outline: none;text-decoration: none;"
end
def fallback_image_tag
content_tag(:img,
:class => 'bodyImage',
:src => "http://#{host}/images/email/email_no_img_s1.gif",
:alt => "No photos yet",
:border => "0",
:width => default_image_size,
:style => image_stylej
).html_safe
end
def actual_image_tag(image, count)
content_tag(:img,
:class => 'bodyImage',
:src => image.src,
:alt => "Click to see #{pluralize(saved_search_property.image_count, 'Photo')}",
:border =>"0",
:width => image_width(image),
:style => image_style
)
end
def image_tag(image, count)
return fallback_image_tag unless image
actual_image_tag(image, count)
end
def saved_search_image_with_attributes(saved_search_property)
first_image = saved_search_property.album.best_first_iamge_for_size(560, 320)
width = image_width(first_image)
a_tag_options = {
:href => "#{auto_login_url}",
:style =>"display: block;text-decoration: none; height: auto; :width => '#{width}';"
}
content_tag(:a, a_tag_options) do
display_updated_attributes_for(saved_search_property) +
image_tag(first_image, saved_search_property.count)
end.html_safe
end
def image_width(image)
return default_image_size unless image
image.width > 0 ? image.width : default_image_size
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment