Sha256: e5b0e824ece18ea733bed8f7bcba310285700d6721f81df69844e77b0b1a54d1

Contents?: true

Size: 1.42 KB

Versions: 16

Compression:

Stored size: 1.42 KB

Contents

# DEPRECATED - use url_media instead
#------------------------------------------------------------------------------
module Liquid
  class UrlAsset < DmCore::LiquidTag
    include ActionView::Helpers::TagHelper 
    include ActionView::Helpers::AssetTagHelper
    include DmCore::UrlHelper
    include DmCore::ParamsHelper
    include DmCore::AccountHelper

    #------------------------------------------------------------------------------
    def render(context)
      if @attributes['version']
        #--- pull from MediaFile object
        src = MediaFile.url_by_name(@attributes['src'], version: @attributes['version'])
      else
        #--- handle like regular url
        src = file_url(@attributes['src'], account_site_assets: context_account_site_assets(context), default_folder: 'media', protected: @attributes['protected'].as_boolean)
      end
      return src.nil? ? '' : src
    end
  
#     def self.details
#       { name: self.tag_name,
#         summary: 'Returns url of an asset',
#         category: 'url',
#         description: <<-END_OF_DESCRIPTION
# Give the location/url of an asset file. It is relative to the site's media directory unless a full path/url is given.
# 
# ~~~
# {% url_asset src: 'library/something.pdf' %}
# ~~~
# END_OF_DESCRIPTION
#       }
#     end
  end
  
  Template.register_tag('url_asset',  UrlAsset)
  Template.register_tag('image_path', UrlAsset)
  Template.register_tag('url_image',  UrlAsset)
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_cms-4.2.3.10 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.9 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.8 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.7 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.6 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.5 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.4 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.3 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.2 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3.1 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.3 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.2.3 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.2.2 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.2.1 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.2 lib/dm_cms/liquid/tags/url_asset.rb
dm_cms-4.2.1.5 lib/dm_cms/liquid/tags/url_asset.rb