The following regexp, should be placed first in the convert_wiki_text block:
text = text.gsub(/\[\[Image\(([a-zA-Z]+\:(\d+\:)?)?([^\)^,]+)[^\)]*\)\]\]/, '!\3!')
The following test cases:
puts convert_wiki_text("[[Image(myimage1.png)]]")
puts convert_wiki_text("[[Image(wiki:myimage2.png)]]")
puts convert_wiki_text("[[Image(ticket:1:myimage3.png)]]")
puts convert_wiki_text("[[Image(myimage4.png, 120px)]]")
puts convert_wiki_text("[[Image(myimage5.png, align=right)]]")
Will then output:
!myimage1.png!
!myimage2.png!
!myimage3.png!
!myimage4.png!
!myimage5.png!
I think the only supported extended Image attribute supported by Redmine is align=right, which could have been converted to:
!>myimage5.png!
...but it's probably pretty rare, and would make the already complex regexp almost unreadable.