Sha256: dd9b32d1d083f09eea055bf8168d13e3b1db1a10146b0683a7dc04f33ba7b408
Contents?: true
Size: 493 Bytes
Versions: 1
Compression:
Stored size: 493 Bytes
Contents
# frozen_string_literal: true class HTMLPipeline class TextFilter # HTML Filter that converts image's url into <img> tag. # For example, it will convert # http://example.com/test.jpg # into # <img src="http://example.com/test.jpg" alt=""/>. class ImageFilter < TextFilter def call(text) text.gsub(%r{(https|http)?://.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?}i) do |match| %(<img src="#{match}" alt=""/>) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
html-pipeline-3.1.0 | lib/html_pipeline/text_filter/image_filter.rb |