Sha256: 45c33df748e988dfa9cc8fd7b453ae901ea900482f966325c2f8ad349289880a
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module PagesCore module Admin module ImageUploadsHelper # Generates tags for an editable dynamic image. def editable_dynamic_image_tag(image, width: 250, caption: false, locale: nil) react_component("EditableImage", editable_image_options( image, width:, caption:, locale: ).merge(width:)) end def image_uploader_tag(name, image, options = {}) opts = { caption: false, locale: nil }.merge(options) react_component("ImageUploader", editable_image_options( image, caption: opts[:caption], locale: opts[:locale] ).merge(attr: name, alternative: opts[:alternative])) end private def editable_image_src_options(image, width) return {} unless image { src: dynamic_image_path(image, size: "#{width * 2}x"), image: ::Admin::ImageResource.new(image).to_h } end def editable_image_options(image, width: 250, caption: false, locale: nil) editable_image_src_options(image, width).merge( width:, caption:, locale: locale || I18n.default_locale, locales: locales_with_dir ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.15.5 | app/helpers/pages_core/admin/image_uploads_helper.rb |