Sha256: 74627150bd11d707b4469e26d8eb441dc79ed0038fad12da5bf1f538a119a071

Contents?: true

Size: 446 Bytes

Versions: 14

Compression:

Stored size: 446 Bytes

Contents

module HTML
  class Pipeline
    # 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(/(https|http)?:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match|
        %|<img src="#{match}" alt=""/>|
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
html-pipeline-2.7.1 lib/html/pipeline/image_filter.rb
html-pipeline-2.7.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.6.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.5.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.4.2 lib/html/pipeline/image_filter.rb
html-pipeline-2.4.1 lib/html/pipeline/image_filter.rb
html-pipeline-2.4.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.3.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.2.4 lib/html/pipeline/image_filter.rb
html-pipeline-2.2.3 lib/html/pipeline/image_filter.rb
html-pipeline-2.2.2 lib/html/pipeline/image_filter.rb
html-pipeline-2.2.1 lib/html/pipeline/image_filter.rb
html-pipeline-2.2.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.1.0 lib/html/pipeline/image_filter.rb