Feature #2047

Add SVG support, like images

Added by Pierre Bertet over 4 years ago. Updated 18 days ago.

Status:NewStart date:2008-10-18
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Attachments
Target version:Candidate for next major release
Resolution:

Description

It would be great if we could :

  • Show attached SVG (no direct download)
  • Insert an SVG file in wiki pages, with a syntax near from "!!"

Syntax proposal :

Wiki : °link/to/svg_file.svg°
HTML : <object data="link/to/svg_file.svg" width="100" height="100" type="image/svg+xml">Error</object>

ananas.svg - Demo: this file will not be displayed, but directly downloaded (34.7 KB) Pierre Bertet, 2008-10-18 01:15

History

#1 Updated by Pierre Bertet over 4 years ago

Update (I forgot the dimensions) :
Wiki : °link/to/svg_file.svg(100x100)°
HTML : <object data="link/to/svg_file.svg" width="100" height="100" type="image/svg+xml">Error</object>

#2 Updated by Oleg Lozinskij about 4 years ago

Pierre Bertet wrote:

Update (I forgot the dimensions) :
Wiki : °link/to/svg_file.svg(100x100)°
HTML : <object data="link/to/svg_file.svg" width="100" height="100" type="image/svg+xml">Error</object>

Exactly what I was looking for :)

It is already available?

#3 Updated by Pierre Bertet about 3 years ago

Any news?

#4 Updated by Karel Pičman 10 months ago

+1

#5 Updated by Karel Pičman 10 months ago

You can display SVG image if you put full URL of the image:

!http://www.redmine.org/attachments/download/1042/ananas.svg!

#6 Updated by Jun NAITOH 9 months ago

+1

patch for trunk.

  • Show attached SVG (no direct download)
    Index: app/models/attachment.rb
    ===================================================================
    --- app/models/attachment.rb    (revision 10173)
    +++ app/models/attachment.rb    (working copy)
    @@ -162,7 +162,7 @@
       end
    
       def image?
    -    !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png)$/i)
    +    !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|svg)$/i)
       end
    
       def thumbnailable?
    
  • Insert attached SVG file in wiki pages, with a syntax near from "!!"
    Index: app/helpers/application_helper.rb
    ===================================================================
    --- app/helpers/application_helper.rb    (revision 10173)
    +++ app/helpers/application_helper.rb    (working copy)
    @@ -572,7 +572,7 @@
         # when using an image link, try to use an attachment, if possible
         if options[:attachments] || (obj && obj.respond_to?(:attachments))
           attachments = options[:attachments] || obj.attachments
    -      text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
    +      text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|svg))"(\s+alt="([^"]*)")?/i) do |m|
             filename, ext, alt, alttext = $1.downcase, $2, $3, $4
             # search for the picture in attachments
             if found = Attachment.latest_attach(attachments, filename)
    

#7 Updated by YT Wu 9 months ago

can this patch support the export to PDF function ( with image in the PDF file ) ?

#8 Updated by Jun NAITOH 9 months ago

YT Wu wrote:

can this patch support the export to PDF function ( with image in the PDF file ) ?

No.
Because, RFPDF library is not supporting SVG file.

#9 Updated by Eugene Seliverstov 3 months ago

Jun NAITOH wrote:

patch for trunk.

Is there a chance to get this small patch in trunk? Manual patches to redmine files is not a best solution.
I think it can't break anything except a missed image in PDF.

#10 Updated by Mischa The Evil 3 months ago

  • Target version set to Candidate for next major release

The patches in note-6 from Jun NAITOH seem feasible.

#11 Updated by Gabriel Mazetto 25 days ago

RFPDF is obsolete, even the author is migrating to Prawn: https://github.com/edwinmoss/rfpdf We should consider migrating too.

#12 Updated by Toshi MARUYAMA 18 days ago

Gabriel Mazetto wrote:

RFPDF is obsolete, even the author is migrating to Prawn: https://github.com/edwinmoss/rfpdf We should consider migrating too.

RFPDF is maintained by Jun NAITOH.
https://github.com/naitoh/rfpdf

Also available in: Atom PDF