Project

General

Profile

Feature #3228 ยป inline-html-images.diff

Patch to inline images as Base64 encoded in exported HTML - Jak Charlton, 2010-08-22 01:21

View differences:

app/helpers/application_helper.rb
495 495
        attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse
496 496
        # search for the picture in attachments
497 497
        if found = attachments.detect { |att| att.filename.downcase == filename }
498
          image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
499 498
          desc = found.description.to_s.gsub('"', '')
500
          if !desc.blank? && alttext.blank?
499
           if !desc.blank? && alttext.blank?
501 500
            alt = " title=\"#{desc}\" alt=\"#{desc}\""
502
          end
503
          "src=\"#{image_url}\"#{alt}"
501
           else
502
            alt = ""
503
           end
504
           
505
           case options[:wiki_links]
506
            when :local
507
              "src=\"data:#{found.content_type};base64,#{Base64.b64encode(File.read(found.diskfile)).gsub(/\n/,"")}\"#{alt}"
508
            when :anchor
509
              "src=\"data:#{found.content_type};base64,#{Base64.b64encode(File.read(found.diskfile)).gsub(/\n/,"")}\"#{alt}"
510
            else
511
              image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
512
              "src=\"#{image_url}#{alt}\""
513
            end
504 514
        else
505 515
          m
506 516
        end
app/views/wiki/export.rhtml
16 16
</style>
17 17
</head>
18 18
<body>
19
<%= textilizable @content, :text, :wiki_links => :local %>
19
	<%= textilizable @content, :text, :wiki_links => :local, :attachments => @content.page.attachments %>
20 20
</body>
21 21
</html>
app/views/wiki/export_multiple.rhtml
27 27
<% @pages.each do |page| %>
28 28
<hr />
29 29
<a name="<%= page.title %>" />
30
<%= textilizable page.content ,:text, :wiki_links => :anchor %>
30
	<%= textilizable page.content ,:text, :wiki_links => :anchor, :attachments => page.attachments %>
31 31
<% end %>
32 32

  
33 33
</body>
    (1-1/1)