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
-
#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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/ecm/pictures_helper.rb', line 28 def (gallery_identifier, picture) = {} # Add gallery identifier for orange box [:rel] = "lightbox[#{gallery_identifier}]" # Add thumbnail class for twitter bootstrap [:class] = 'thumbnail' # build the caption caption = '' caption << "<div class=\"caption-name\">#{picture.name}</div>" unless picture.name.blank? caption << "<div class=\"caption-description\">#{picture.description}</div>" unless picture.description.blank? [:"data-ob_caption"] = caption if caption.size > 0 end |
#render_picture(name, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/ecm/pictures_helper.rb', line 46 def render_picture(name, = {}) .reverse_merge!( preview_style: :thumb, plain: false, img_css_class: nil ) img_css_class = .delete(:img_css_class) plain = .delete(:plain) picture = Ecm::Pictures::Picture.where(name: name.to_s).first if picture.nil? return content_tag(:div, class: 'warning missing picture') do content_tag(:p, I18n.t('ecm.pictures.picture.warnings.missing', name: name.to_s)) end end if plain image_tag picture.image.url, class: img_css_class else render picture end rescue Exception => e return e. 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 |
# File 'app/helpers/ecm/pictures_helper.rb', line 10 def render_picture_gallery(name, = {}) = { preview_style: :thumb }.merge() gallery = Ecm::Pictures::Gallery.where(name: name.to_s).first if gallery.nil? content_tag(:div, class: 'warning missing gallery') do content_tag(:p, I18n.t('ecm.pictures.gallery.warnings.missing', name: name.to_s)) end else render gallery, { view: self } end rescue Exception => e return e. end |