Sha256: df99a26f4182d7a3676c1ffa26a5c0d249c455318e8c1ecb7cf7d9252edef606

Contents?: true

Size: 448 Bytes

Versions: 11

Compression:

Stored size: 448 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

11 entries across 11 versions & 1 rubygems

Version Path
html-pipeline-2.11.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.10.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.9.2 lib/html/pipeline/image_filter.rb
html-pipeline-2.9.1 lib/html/pipeline/image_filter.rb
html-pipeline-2.9.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.8.4 lib/html/pipeline/image_filter.rb
html-pipeline-2.8.3 lib/html/pipeline/image_filter.rb
html-pipeline-2.8.2 lib/html/pipeline/image_filter.rb
html-pipeline-2.8.1 lib/html/pipeline/image_filter.rb
html-pipeline-2.8.0 lib/html/pipeline/image_filter.rb
html-pipeline-2.7.2 lib/html/pipeline/image_filter.rb