Method: Tenon::ApplicationHelper#first_image
- Defined in:
- app/helpers/tenon/application_helper.rb
#first_image(obj, options = {}) ⇒ Object
eg. first_image(@product)
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/tenon/application_helper.rb', line 41 def first_image(obj, = {}) opts = { collection: :images, method: :image, style: :thumbnail, default: image_path('noimage.jpg') }.merge(.symbolize_keys!) image = obj.send(opts[:collection]).first image ? image.send(opts[:method]).url(opts[:style]) : opts[:default] end |