Method: Jets::AssetTagHelper#asset_path

Defined in:
lib/jets/overrides/rails/asset_tag_helper.rb

#asset_path(source, options = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/jets/overrides/rails/asset_tag_helper.rb', line 37

def asset_path(source, options = {})
  source = source.to_s # convert to String because passing a posts.photo object to results in failure to resolve the immage to a URL since we haven't defined polymorphic_url yet
  # mimic original behavior to get /images in source
  source = "/images/#{source}" unless source.starts_with?('/') || source.starts_with?('http')

  # Examples to help understand:
  #
  #   puts "AssetTagHelper#asset_path source #{source}"
  #   puts "AssetTagHelper#asset_path asset_folder?(source) #{asset_folder?(source).inspect}"
  #   AssetTagHelper#asset_path source /packs/images/myimage-e5f675d1ba26865fd65e919beb5bb86b.png
  #   AssetTagHelper#asset_path asset_folder?(source) "images"
  #
  if on_aws? && asset_folder?(source) && !source.starts_with?('http')
    source = "#{s3_public}#{source}"
  end

  super
end