Module: RailsConnector::CmsAssetHelper
- Defined in:
- app/helpers/rails_connector/cms_asset_helper.rb
Overview
This module contains helpers that can be used to reference images and other assets stored in the CMS.
Instance Method Summary collapse
-
#cms_image_tag(*args) ⇒ String
Calculates an HTML image tag for an image stored in the CMS.
Instance Method Details
#cms_image_tag(target, tag_options = {}) ⇒ String #cms_image_tag(obj, linklist, tag_options = {}, editing_options = {}) ⇒ String
Note:
There are two different signatures of this method: the first one generates an HTML image tag with no inplace editing possible, the second one generated an HTML image tag for inplace editing.
Calculates an HTML image tag for an image stored in the CMS.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/rails_connector/cms_asset_helper.rb', line 43 def cms_image_tag(*args) if args.second.nil? || args.second.is_a?(Hash) target = args.first if target.is_a?(LinkList) ActiveSupport::Deprecation.warn(%{ Calling "cms_image_tag" with a "LinkList" is not allowed anymore. Please use following syntax instead: cms_image_tag(@obj, :linklist). }) end = args.second || {} .symbolize_keys! [:src] = cms_path(target) [:alt] ||= display_title(target) else obj = args.first attribute_name = args.second target = obj[attribute_name] = args.third || {} = args.fourth || {} .symbolize_keys! .symbolize_keys! [:src] ||= begin target_path = cms_path(target) if target_path == RailsConnector::DefaultCmsRoutingHelper::LINK_TO_EMPTY_LINKLIST [:placeholder] || image_path('rails_connector/image_placeholder.png') else target_path end end if inplace_editing_allowed? .merge!( 'data-ip-resource-source-obj-id' => obj.id, 'data-ip-resource-source-field-name' => attribute_name ) end .reverse_merge!(alt: display_title(target)) end tag('img', ) end |