Sha256: 0bce69280724408ee0207d1e3b76113fdcd9166b68cabfb09ebfc7c420110bc5

Contents?: true

Size: 488 Bytes

Versions: 9

Compression:

Stored size: 488 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.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

9 entries across 9 versions & 1 rubygems

Version Path
html-pipeline-3.0.3 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.2 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.1 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.0 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.0.pre6 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.0.pre5 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.0.pre3 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.0.pre2 lib/html_pipeline/text_filter/image_filter.rb
html-pipeline-3.0.0.pre1 lib/html_pipeline/text_filter/image_filter.rb