Module: Ecm::PicturesHelper
- Defined in:
- app/helpers/ecm/pictures_helper.rb
Instance Method Summary collapse
-
#build_link_options_for_picture_in_gallery(gallery_identifier, picture) ⇒ Object
helper method to build link options for images inside a gallery.
-
#render_picture(name, options = {}) ⇒ Object
TODO: Implement this.
-
#render_picture_gallery(name, options = {}) ⇒ Object
renders picture galleries in your views.
Instance Method Details
#build_link_options_for_picture_in_gallery(gallery_identifier, picture) ⇒ Object
helper method to build link options for images inside a gallery.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/ecm/pictures_helper.rb', line 49 def (gallery_identifier, picture) = {} # Add gallery identifier for orange box = { :rel => "lightbox[#{gallery_identifier}]" } # build the caption = "" << "<span class=\"caption-name\">#{picture.name}</span>" unless picture.name.blank? << "<span class=\"caption-description\">#{picture.description}</span>" unless picture.description.blank? [:"data-ob_caption"] = if .size > 0 return end |
#render_picture(name, options = {}) ⇒ Object
TODO: Implement this.
65 66 |
# File 'app/helpers/ecm/pictures_helper.rb', line 65 def render_picture(name, = {}) end |
#render_picture_gallery(name, options = {}) ⇒ Object
renders picture galleries in your views
Usage
Assume you have created a picture gallery named “Holidays 2012”. You can render it in your view as follows:
<%= render_picture_gallery 'Holidays 2012' %>
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 37 38 39 40 41 42 43 44 45 46 |
# File 'app/helpers/ecm/pictures_helper.rb', line 10 def render_picture_gallery(name, = {}) begin = {:preview_style => :thumb}.merge() gallery = Ecm::Pictures::PictureGallery.where(:name => name.to_s).first gallery_identifier = gallery.to_param rescue 'missing' content_tag(:div, :class => 'picture-gallery', :id => "picture-gallery-#{gallery_identifier}") do if gallery.nil? content_tag(:span, :class => 'warning') do I18n.t('ecm.pictures.warnings.missing_gallery', :name => name.to_s) end else content_tag(:h1, gallery.name) + content_tag(:p, gallery.description, {:class => 'picture-gallery-description'}) + content_tag(:ul, {:class => 'pictures'}) do gallery.pictures.collect do |picture| content_tag(:li, {:class => 'picture', :id => "picture-#{picture.to_param}"}) do concat(content_tag(:h2, picture.name, :class => 'picture-name')) unless picture.name.blank? # Check if we should link images or not. if gallery.link_images = (gallery_identifier, picture) concat(link_to(image_tag(picture.image.url([:preview_style]), :alt => picture.description), "#{picture.image.url}#{File.extname(picture.image_file_name)}", )) else concat(image_tag(picture.image.url([:preview_style]), :alt => picture.description)) end concat(content_tag(:div, picture.description, :class => 'picture-description')) end end.join.html_safe end.html_safe end end.html_safe rescue Exception => e return e. end end |