Module: Ires::ViewHelper
- Defined in:
- lib/ires/view_helper.rb
Instance Method Summary collapse
-
#ires_tag(path:, width:, height:, mode: 'resize', expire: 30.days, **option) ⇒ Object
Image resize return [image_tag].
Instance Method Details
#ires_tag(path:, width:, height:, mode: 'resize', expire: 30.days, **option) ⇒ Object
Image resize return [image_tag]
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 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ires/view_helper.rb', line 9 def ires_tag(path:, width:, height:, mode: 'resize', expire: 30.days, **option) full_path = image_full_path(path.to_s) # if no image or could not find file path then perform the same action as 'image_tag' return image_tag(path, option) if !File.exist?(full_path) && !full_path.include?("http") # Expiration date (default: 7.days) # ex. "20170101" expiration_date = (Date.today + expire).strftime('%Y%m%d') # Reszie image case mode when 'resize' @image = Ires::Service.resizeImage( full_path, width, height, image_dir, expiration_date) when 'crop' @image = Ires::Service.cropImage( full_path, width, height, image_dir, expiration_date) when 'resize_to_crop' @image = Ires::Service.resizeToCropImage( full_path, width, height, image_dir, expiration_date) end return nil if @image.nil? # Set image_tag image_tag(@image, option) end |