Project

General

Profile

Defect #10189 » images_with_space.patch

Please test and feedback. No changes to Redmine syntax - Paulo Neves, 2013-12-15 14:12

View differences:

app/helpers/application_helper.rb 2013-12-15 11:45:55.960476540 +0000 → helpers/application_helper.rb 2013-12-15 12:49:41.032533340 +0000
573 573
          m
574 574
        end
575 575
      end
576
	text.gsub!(/!([^(!]+?)(\.bmp|gif|jpg|jpe|jpeg|png)\s?(?:\(((?:[^\(\)]|\([^\)]+\))+?)\))?\!/i) do |m|
577
        filename= $1.downcase+$2
578
	alt =  "alt=\"#{$3}\""
579
        # search for the picture in attachments
580
        if found = Attachment.latest_attach(attachments, filename)
581
          image_url = download_named_attachment_path(found, found.filename, :only_path => only_path)
582
          desc = found.description.to_s.gsub('"', '')
583
          if !desc.blank? 
584
            alt = " title=\"#{desc}\" alt=\"#{desc}\""
585
          end
586
          "<img src=\"#{image_url}\"#{alt} />"
587
        else
588
          m
589
        end
590
       end
591
      #One last effort to catch an attached image
576 592
    end
577 593
  end
(5-5/5)