Method: Tenon::ApplicationHelper#first_image
- Defined in:
- app/helpers/tenon/application_helper.rb
#first_image(obj, options = {}) ⇒ Object
eg. first_image(@product)
54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/tenon/application_helper.rb', line 54 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 |