Sha256: 612020bedafb04f3e373e0ae78b0b8596ef97965b3077b517853c506af5d75bd
Contents?: true
Size: 431 Bytes
Versions: 1
Compression:
Stored size: 431 Bytes
Contents
# frozen_string_literal: true module AutoHtml # Image filter class Image def initialize(proxy: nil, alt: nil) @proxy = proxy || '' @alt = alt end def call(text) text.gsub(image_pattern) do |match| TagHelper.tag(:img, src: @proxy + match, alt: @alt) end end private def image_pattern %r{(?<!src=")https?://.+?\.(jpg|jpeg|bmp|gif|png)(\?\S+)?}i end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
auto_html-2.0.2 | lib/auto_html/image.rb |