Sha256: 0abf1fc77a163ad801590eef71960d71d3353428be09a2814d3bf7d9d102b6f7
Contents?: true
Size: 901 Bytes
Versions: 3
Compression:
Stored size: 901 Bytes
Contents
module PandaCms module EditorJs module Blocks class Image < Base def render url = data["url"] caption = sanitize(data["caption"]) with_border = data["withBorder"] with_background = data["withBackground"] stretched = data["stretched"] css_classes = ["prose"] css_classes << "border" if with_border css_classes << "bg-gray-100" if with_background css_classes << "w-full" if stretched html_safe(<<~HTML) <figure class="#{css_classes.join(" ")}"> <img src="#{url}" alt="#{caption}" /> #{caption_element(caption)} </figure> HTML end private def caption_element(caption) return "" if caption.blank? "<figcaption>#{caption}</figcaption>" end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
panda_cms-0.6.3 | app/lib/panda_cms/editor_js/blocks/image.rb |
panda_cms-0.6.2 | app/lib/panda_cms/editor_js/blocks/image.rb |
panda_cms-0.6.1 | app/lib/panda_cms/editor_js/blocks/image.rb |