Sha256: 941e19fa5f13c2360d32850cdceb41cf7e1cc11ca84d9ecd23b651606bb931cd

Contents?: true

Size: 1.61 KB

Versions: 7

Compression:

Stored size: 1.61 KB

Contents

<%=
# Set parameter for size, small|medium|large if you like
size ||= "medium"
fix_size ||= true

# small med and x-large correspond roughly to amazon sm, med and lg. 
# large corresponds roughly to google medium. Just one dimension to
# prevent disproportionate scaling. We use CSS so we can set maximums
# in BOTH dimensions but let aspect ratio remain the same. We put it
# inline so HTML Snippet API clients get images constrained to reasonable
# sizes without extra CSS. IE6 won't do max-height/max-width, sorry IE6, no
# way to accomodate you (trying to put a width and a max-width triggers
# weird IE8 bugs!). Best we can do.
#
# generally the 'max-height' is our operative maximum for ordinary ratios,
# but we let the width be more than the height for weird ratio'd covers
# that are wider than square. 
dimensions_style = { 
          "small"       => "max-height: 80px; max-width: 100px;",
          "medium"      => "max-height: 160px; max-width: 200px;",
          "large"       => "max-height: 200px; max-width: 240px;",
          "extra-large" => "max-height: 475px; max-width: 570px;" }

img_st = cover_image_response(size)
if img_st 
  img_data = img_st.view_data
  img_params = {'src'=>img_data[:url],
  'class'=>'cover_image',
  'alt'=>h(img_data[:display_text])}
  # If we're in https mode, and the original url is http, use
  # Umlaut proxy to avoid browser security warning. 
  if (request.protocol != img_params['src'][0..6])
    img_params['src'] = url_for(:controller => "resource", :action => "proxy", :id => img_st.id )
  end
  img_params.merge!( "style" => dimensions_style[size]) if fix_size
  tag('img', img_params )
end %>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
umlaut-3.3.1 app/views/resolve/_cover_image.html.erb
umlaut-3.3.0 app/views/resolve/_cover_image.html.erb
umlaut-3.2.0 app/views/resolve/_cover_image.html.erb
umlaut-3.1.1 app/views/resolve/_cover_image.html.erb
umlaut-3.1.0 app/views/resolve/_cover_image.html.erb
umlaut-3.1.0.pre2 app/views/resolve/_cover_image.html.erb
umlaut-3.1.0.pre1 app/views/resolve/_cover_image.html.erb