Project

General

Profile

Feature #24922 » 0001-Add-support-for-2x-3x-etc.-hires-images.patch

Jan from Planio www.plan.io, 2017-01-25 17:12

View differences:

app/helpers/application_helper.rb
636 636

  
637 637
    parse_sections(text, project, obj, attr, only_path, options)
638 638
    text = parse_non_pre_blocks(text, obj, macros) do |text|
639
      [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
639
      [:parse_inline_attachments, :parse_hires_images, :parse_wiki_links, :parse_redmine_links].each do |method_name|
640 640
        send method_name, text, project, obj, attr, only_path, options
641 641
      end
642 642
    end
......
681 681
    parsed
682 682
  end
683 683

  
684
  # add srcset attribute to img tags if filename includes @2x, @3x, etc.
685
  # to support hires displays
686
  def parse_hires_images(text, project, obj, attr, only_path, options)
687
    text.gsub!(/src="([^"]+@(\dx)\.(bmp|gif|jpg|jpe|jpeg|png))"/i) do |m|
688
      filename, dpr = $1, $2
689
      m + " srcset=\"#{filename} #{dpr}\""
690
    end
691
  end
692

  
684 693
  def parse_inline_attachments(text, project, obj, attr, only_path, options)
685 694
    return if options[:inline_attachments] == false
686 695

  
(1-1/2)