Sha256: 1844fc4507e987d22ffeda74ac4f01435d8788d1bdad37fa21a055c6aef0b723

Contents?: true

Size: 1.87 KB

Versions: 105

Compression:

Stored size: 1.87 KB

Contents

<%
img       = block.child('image_src')
img_style = block.child('image_style').value.to_sym
link      = block.child('link').value
align     = block.child('align').value
width     = block.child('width').value
height    = block.child('height').value
mt        = block.child('margin_top').value.downcase
mr        = block.child('margin_right').value.downcase
mb        = block.child('margin_bottom').value.downcase
ml        = block.child('margin_left').value.downcase
url = img && img.image ? img.image.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

105 entries across 105 versions & 1 rubygems

Version Path
caboose-cms-0.4.127 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.126 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.125 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.124 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.123 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.122 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.121 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.120 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.119 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.118 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.117 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.116 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.115 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.114 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.113 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.112 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.111 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.110 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.109 app/views/caboose/blocks/_image.html.erb
caboose-cms-0.4.108 app/views/caboose/blocks/_image.html.erb