Sha256: 25da961f89f34f9e3fedcdca8c96049ff8de3ee45c59b6e0da39b3916f6ee905

Contents?: true

Size: 1.98 KB

Versions: 444

Compression:

Stored size: 1.98 KB

Contents

<%
img       = block.child_value('image_src')
img_style = block.child_value('image_style')
link      = block.child_value('link')
align     = block.child_value('align')
width     = block.child_value('width')
height    = block.child_value('height')
mt        = block.child_value('margin_top')
mr        = block.child_value('margin_right')
mb        = block.child_value('margin_bottom')
ml        = block.child_value('margin_left')
mt.downcase! if mt 
mr.downcase! if mr 
mb.downcase! if mb 
ml.downcase! if ml 
url = img ? img.url(img_style.downcase.to_sym) : nil

img = nil
alt = block.child_value('alt_text').blank? ? "" : block.child_value('alt_text')
if url && !url.include?('missing.png')  
  style = []
  if align == 'Center'
    ml = 'auto'
    mr = 'auto'
    style << "display: block"
  end
  
  ml = "#{ml}px" if ml && ml != 'auto' && !ml.ends_with?('px') && !ml.ends_with?('em') && !ml.ends_with?('%') 
  mr = "#{mr}px" if mr && mr != 'auto' && !mr.ends_with?('px') && !mr.ends_with?('em') && !mr.ends_with?('%')
  mt = "#{mt}px" if mt && mt != 'auto' && !mt.ends_with?('px') && !mt.ends_with?('em') && !mt.ends_with?('%')
  mb = "#{mb}px" if mb && mb != 'auto' && !mb.ends_with?('px') && !mb.ends_with?('em') && !mb.ends_with?('%')
  
  style << "width: #{width}px"       if width
  style << "max-height: #{height}px" if height
  style << "float: left"             if align == 'Left'
  style << "float: right"            if align == 'Right'
  style << "margin-left:   #{ml}"    if ml
  style << "margin-right:  #{mr}"    if mr
  style << "margin-top:    #{mt}"    if mt
  style << "margin-bottom: #{mb}"    if mb  
  style = style.join('; ')  
  
  img = "<img src='#{url}' style='#{style}' id='block_#{block.id}' alt='#{alt}' />"
  if link && link.strip.length > 0
    if editing
      img = "<a href='#'>#{img}</a>"            
    else
      img = "<a href='#{link}'>#{img}</a>"
    end
  end
end 
if editing && img.nil?
  %><p id='block_<%= block.id %>'>Please upload an image.</p><%
else
  %><%= raw img %><%
end
%>

Version data entries

444 entries across 444 versions & 1 rubygems

Version Path
caboose-cms-0.9.150 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.149 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.148 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.147 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.146 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.145 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.144 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.143 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.142 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.141 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.140 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.139 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.138 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.137 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.136 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.135 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.134 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.133 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.132 app/views/caboose/blocks/_image2.html.erb
caboose-cms-0.9.131 app/views/caboose/blocks/_image2.html.erb