images_with_space.patch

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

Download (909 Bytes)

View differences:

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