Sha256: c220b7d8b6880d70bbfad6af085c531a245691cf24ac574f30ceccde9dccdfaf

Contents?: true

Size: 1.85 KB

Versions: 43

Compression:

Stored size: 1.85 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').downcase
mr        = block.child_value('margin_right').downcase
mb        = block.child_value('margin_bottom').downcase
ml        = block.child_value('margin_left').downcase
url = img ? img.url(img_style.downcase.to_sym) : nil

img = nil
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}' />"
  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

43 entries across 43 versions & 1 rubygems

Version Path
caboose-cms-0.5.20 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.19 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.17 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.16 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.15 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.14 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.13 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.12 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.11 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.10 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.9 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.8 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.7 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.6 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.5 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.4 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.3 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.2 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.5.1 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.151 app/views/caboose/blocks/_image.html.erb