Module: Ecm::PicturesHelper

Defined in:
app/helpers/ecm/pictures_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_picture(name, options = {}) ⇒ Object



38
39
# File 'app/helpers/ecm/pictures_helper.rb', line 38

def render_picture(name, options = {})
end


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/ecm/pictures_helper.rb', line 2

def render_picture_gallery(name, options = {})
  begin  
    options = {:preview_style => :thumb}.merge(options)
    
    gallery = Ecm::Pictures::PictureGallery.where(:name => name.to_s).first
    gallery_identifier = gallery.to_param rescue 'missing'

    (:div, :class => 'picture-gallery', :id => "picture-gallery-#{gallery_identifier}") do
      if gallery.nil?
        (:span, :class => 'warning') do
          I18n.t('ecm.pictures.warnings.missing_gallery', :name => name.to_s)
        end      
      else
        (:h1, gallery.name) +
        (:ul, {:class => 'pictures'}) do
          gallery.pictures.collect do |picture|
           (:li, {:class => 'picture', :id => "picture-#{picture.to_param}"}) do
              concat((:h2, picture.name, :class => 'picture-name')) unless picture.name.blank?
              
              # Check if we should link images or not.
              if gallery.link_images
                concat(link_to(image_tag(picture.image.url(options[:preview_style]), :alt => picture.description), "#{picture.image.url}#{File.extname(picture.image_file_name)}", {:rel => "lightbox[#{gallery_identifier}]"}))
              else 
                concat(image_tag(picture.image.url(options[:preview_style]), :alt => picture.description))
              end
              concat((:div, picture.description, :class => 'picture-description'))
            end
          end.join.html_safe
        end.html_safe
      end
    end.html_safe
  rescue Exception => e
    return e.message
  end  
end