Sha256: 21e286c9cd7ad10f31c95cd4c0a0cdc1e9cb61ca2f9636b04f5b3d3abe4c10f4

Contents?: true

Size: 530 Bytes

Versions: 5

Compression:

Stored size: 530 Bytes

Contents

description 'Add query parameter "aspect" to images'

Filter.create :fix_img_tag do |context, content|
 content.gsub!(/(<img[^>+]src=")([^"]+)"/) do |match|
    prefix, path = $1, $2
    if path =~ %r{^w+://} || path.starts_with?(build_path('_')) ||
        (path.starts_with?('/') && !path.starts_with?(build_path(''))) ||
        path.include?('aspect=')
      match
    else
      path = unescape_html(path)
      prefix + escape_html(path + (path.include?('?') ? '&' : '?') + 'aspect=image') + '"'
    end
  end
  content
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
olelo-0.9.4 plugins/filters/fix_img_tag.rb
olelo-0.9.3 plugins/filters/fix_img_tag.rb
olelo-0.9.2 plugins/filters/fix_img_tag.rb
olelo-0.9.1 plugins/filters/fix_img_tag.rb
olelo-0.9.0 plugins/filters/fix_img_tag.rb