ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

Textile support for scale inlined images

Added by Dirk Heinze at 2013-03-21 10:17 am

Hello,

I use redmine and chilliproject for different tasks.
And i work with an Retina Mac.
So my screenshots are much bigger today than earlier.
In Issues and Wiki-Articles the images are to large in chiliproject.

In Redmine it's easy to fix this with

!{width:50%}image.png}!

But this doesn't work in chilliproject.

Has anyone an idea how to fix this?

I use: ChiliProject 3.3.0.080c5b63c (Mysql2) and Redmine 2.2.3.stable.9007 both with PlugIn WikiNG 0.3
The scaling tag works without WikiNG.


Replies (4)

RE: Textile support for scale inlined images - Added by Chris Dähn at 2013-03-22 01:43 am

Hi,

you're right - seems to be a missing handling for the size tag:

!{width=32px;height=64px}images/foo.png!
!{width=50%}images/foo.png!

Currently the support for image height is commented out / incomplete - see:

lib/redcloth3.rb line 945

    def inline_textile_image( text )
        text.gsub!( IMAGE_RE )  do |m|
            stln,algn,atts,url,title,href,href_a1,href_a2 = $~[1..8]
            htmlesc title
            atts = pba( atts )
            atts = " src=\"#{ htmlesc url.dup }\"#{ atts }" 
            atts << " title=\"#{ title }\"" if title
            atts << " alt=\"#{ title }\"" 
            #size = @getimagesize($url);
            #if($size) $atts.= " $size[3]";

The function getimagesize() seems to be missing and should have the task to evaluate the {width:xxx} part of the URL.

=> after a look into Redmine sources, the both lines are disabled there, too... so the error is a layer below that...

The next step would be to open an issue ticket so Felix or Holger can check and possibly solve that...

Or can I port it back from Redmine to CP? (With some hints I can do that maybe even with my noob-skills in Ruby?) ;-)

ciao,
Chris

RE: Textile support for scale inlined images - Added by Dirk Heinze at 2013-03-22 08:09 am

Thank, you Chris for the fast reply.

I checked the code between redmine and chilliproject.
In this section has red mine the same comments.
So the solution should be at another place.

But i think in the moment, that the other changes in lib/redcloth3.rb may be a solution.
I will check this on the coming weekend, when no production runs on the server.

ciao
Dirk

RE: Textile support for scale inlined images - Added by Felix Schäfer at 2013-03-22 10:57 am

Textile optionally supports arbitrary CSS, this has security implications though and could lead to XSS attacks, thus it is disabled in ChiliProject. IIRC it's just a switch to flip to get it back, I can't remember off the top of my head where it is though.

RE: Textile support for scale inlined images - Added by Dirk Heinze at 2013-03-23 02:58 pm

problem solved!

I'v updated the lib/redcloth3.rb with the version distributed by redmine 2.2.3.

And i'v disabled the style filtering by change in lib/redmine/wiki_formatting/textile/formatter.rb line 30 from true to false.

 1#-- encoding: UTF-8
 2#-- copyright
 3# ChiliProject is a project management system.
 4#
 5# Copyright (C) 2010-2012 the ChiliProject Team
 6#
 7# This program is free software; you can redistribute it and/or
 8# modify it under the terms of the GNU General Public License
 9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# See doc/COPYRIGHT.rdoc for more details.
13#++
14
15require 'redcloth3'
16
17module Redmine
18  module WikiFormatting
19    module Textile
20      class Formatter &lt; RedCloth3
21        include ActionView::Helpers::TagHelper
22
23        # auto_link rule after textile rules so that it doesn't break !image_url! tags
24        RULES = [:textile, :block_markdown_rule, :inline_auto_link, :inline_auto_mailto]
25
26        def initialize(*args)
27          super
28          self.hard_breaks=true
29          self.no_span_caps=true
30          self.filter_styles=false # false activates the styles in wiki formatting 
31        end
32
33        def to_html(*rules)
34          @toc = []
35          super(*RULES).to_s
36        end

But the is an tiny bug in combination with tables, if you embed the image in an table.
Than all scales below 100% produces thumbnails.

(1-4/4)