Redmine - Defect #10189
Inline image does not work with spaces in file name2012-02-09 21:37 - Jason Palmer

ステータス:

New

開始日:

優先度:

Normal

期日:

担当者:
カテゴリ:

Text formatting

進捗率:

0%

予定工数:

0.00時間Affected version:

1.3.0

対象バージョン:Resolution:
説明Now that Redmine does not replaced special characters in attachment filenames, you cannot display an image attachment inline
when the attachment name has spaces in it.
e.g.:!SampleImage.png!

will

not,

as

will

notwork,

it

does

not

recognisethisasacomplete

image

reference!Sample Image.png!
!Sample̲Image.png!
!"Sample
Sample̲Image.png
Image.png"!

will

notwork,

asit

thereisdoesn'tnoseem

attachment
torespectwiththethisnamequotes

toenclose

thefilename!"Sample Image.png"!
If you rename the file so that it does not containe spaces it does work

!SampleImage2.png!

willwork

I SampleImage2.png
know it is best practice to name files without spaces, but the users have been used to working with the underscores for a couple ofyears now. What is the best way to reference the attachment (containing spaces in the name) or revert to the previous file handling(less preferable).
関連するチケット:
関連している Redmine - Defect #10182: UTF and Attachments

New

関連している Redmine - Feature #26071: Generate markup for uplo...

Closed次のチケットが重複 Redmine - Defect #17679: Attached inline image ...

Closed次のチケットが重複 Redmine - Defect #13375: Inline Image formattin...

Closed履歴#1 - 2012-02-09 21:42 - Jason Palmer
Sorry, I missed a slash on one of the pre tags

!SampleImage.png!

will

not,

aswillnotwork,

it

does

not

recognisethisasacomplete

image

reference!Sample Image.png!
!Sample̲Image.png!
Sample̲Image.png!"Sample Image.png"!

will

notwork,asittheredoesn'tisnoseem

attachment

torespectwiththethisnamequotes

toenclose

thefilename!"Sample Image.png"!

If you rename the file so that it does not containe spaces it does work

2024-09-27

1/5

!SampleImage2.png!

willwork

SampleImage2.png#2 - 2012-02-28 16:45 - Vitaly Klimov
It also concerns filenames with parentheses in name, because redcloth parser uses text in parentheses inside image tag as an image title. So i guess
one should patch redcloth or fall back to the old file naming rules#3 - 2012-02-28 18:41 - Etienne Massip- 説明 を更新#4 - 2012-03-06 10:54 - fangzheng (方正)Really important issue.
Watch it and wait for developer's feedback.
#5 - 2012-04-19 14:41 - Mirko Geissler
Still present in 1.4.0 it seems!
#6 - 2012-04-19 15:14 - Jean-Philippe Lang
Textile syntax does not support spaces in image names. If you want to display your image inline, don't use spaces in its name.
#7 - 2012-04-19 23:46 - Jason Palmer
I figured that textile did not support spaces in the filenames - I was unable to find out how to wrap the filename to ensure it was parsed correctly todisplay the inline image. This is one effect of the system no longer renaming file attachments to replace unsupported characters with a (predictable)
close approximation of the original name. The bulk of our attachments are now a stored as a hash of the original file name.
That being said, I do appreciate the system preserving the original file name. Perhaps best practice for us moving forward is just to ensure that files
are named appropriately prior to being attached, until someone can find a method of passing the attachment name to the inline image function (orother function that does not support files with spaces). Is it possible to lookup and pass the hashed filename to the inline image function if theoriginal filename containing spaces is entered?
e.g. entering!SampleImage.png!

becomes!53616d706c6520496d616765.png!
automatically, and the image is displayed?
#8 - 2012-11-19 03:34 - Dicky Hadiyuwono- ファイル space̲in̲inline̲image̲filename.patch を追加
This prove to be crucial with our workflow since Skitch uses space in its output file.
I've made a workaround by simply substituting space with %20.
eg. !Photo Skitch Document.png! -> !Photo%20Skitch%20Document.png!
#9 - 2012-11-19 04:13 - Jason Palmer
In the newer releases of Redmine, I have noticed that the thumbnail feature seems to be able to deal with the spaces in attachment names (either
that or one of the Redmine admins at our site toggled a switch to prevent the renaming). Thumbnails are usually better for our use, though we dostill need to actually embed the full-sized images from time to time.
{{SampleImage.png,size=150,title=Thumbnail)}}{{Sample Image.png, size=150, title=Thumbnail)}}#10 - 2012-12-07 01:37 - Philipp erpel
Here's another workaround:
Sample Image.png
Just use a url starting from root:2024-09-27

2/5

!/attachments/download/7187/Sample%20Image.png!
It would also work with http://www.redmine.org/attachments/download/7187/Sample%20Image.png but then you have the host part permanently
in your content and that might not be so cool.
#11 - 2013-12-04 00:19 - Jeff Fendley- ファイル unescape̲inline̲attachment̲filename.patch を追加
Dicky Hadiyuwono wrote:
This prove to be crucial with our workflow since Skitch uses space in its output file.
I've made a workaround by simply substituting space with %20.
eg. !Photo Skitch Document.png! -> !Photo%20Skitch%20Document.png!

I'm migrating another wiki to Redmine and this solution works great. It doesn't require changes to the Textile parser or your filenames, it just makes
escaping work properly. I suggest using CGI.unescape, though, since that would fix the parentheses problem, e.g. for<img src="rex(dog).jpg" alt="My dog, Rex" />write!rex%28dog%29.jpg(My dog, Rex)!
#12 - 2013-12-05 20:14 - Paulo Neves
Hi this Issue is so important. I was going in circles trying to find why my images were not showing up. It seems that they all had spaces. Why thehell is this not a major bug?
Jeff: Your patch only corrects what is newly attached, not the already existing attached images, am i correct? Also I find asking a user to messaround with %20s and the like a bit out of line for non techie people. I am currently looking into the textile regex, but if I am correct the problem
was with Redmine abusing the inline image system.
Thank you for your patches in the mean time.
#13 - 2013-12-12 20:16 - Steffen Hartmann
Philipp erpel wrote:
Here's another workaround:
Sample Image.png
Just use a url starting from root:[...]
It would also work with http://www.redmine.org/attachments/download/7187/Sample%20Image.png but then you have the host part
permanently in your content and that might not be so cool.

This works for me too with redmine 2.3.3 but it's hard to find out the file number 7187 before actually uploading (i.e. for preview).
#14 - 2013-12-15 14:13 - Paulo Neves- ファイル images̲with̲space.patch を追加
I have taken a different approach that tries not to break the existing images with space, as well as the new ones.
I haven't run Redmine tests with it but I think they should pass.
The way the patch works is by adding additional processing to the parse̲inline̲attachments. This method is originally responsible for detecting
inlined images that exist as attachments. This function is responsible for overriding the normal functionality of Redcloth. Redcloth intends themechanism ! ! to be used with fully qualified image urls or images with relative names. This function basically processes wrong <img src> generated
by redcloth and corrects it to point to the attachment.
My patch tries to find ! ! which were not processed at all by Redcloth because they had unsupported syntax (like having space inside the block). This
patch makes a last effort to catch the unparsed ! ! without requiring any change to both Redcloth nor Redmine image syntax.
I have found this regression on redcloth but it hasn't been corrected since 2009 and the mantainer seems to have given up. I think the problem is in
the way the attributes of the images are separated from the source by a space. To allow for both images with spaces in them and space separated
attributes is almost impossible, at least without any complicated logic that figures out if a part of the string are attributes or a filename of an image.
Below is the regular expression used by Redcloth:2024-09-27

3/5

IMAGE̲RE=/(>¦\s¦^)# start of line?
\!
# opening(\<¦\=¦\>)?
# optional alignment atts(#{C})# optional style,class atts(?:\. )?
# optional dot-space([^\s(!]+?)# presume this is the src\s?
# optional space(?:\(((?:[^\(\)]¦\([^\)]+\))+?)\))?
# optional title\!
# closing(?::#{ HYPERLINK })? # optional href/x
I hope it helps.
#15 - 2014-05-21 09:25 - T Leish
Added an image menu plugin that helps with this issue:"The image menu button detects if there are spaces and inserts a modified path to support spaces file name."

Redmine jsToolbar Images Extension#16 - 2014-08-20 14:00 - Jānis Elmeris
Dicky Hadiyuwono wrote:
This prove to be crucial with our workflow since Skitch uses space in its output file.
I've made a workaround by simply substituting space with %20.
eg. !Photo Skitch Document.png! -> !Photo%20Skitch%20Document.png!

Still doesn't work (in 2.3.4). Also, the space replaced with '%20' doesn't work, the path is not resolved to where the image is located.
#17 - 2014-08-20 18:31 - T Leish
My experience with image space names and Redmine is:

Doesn't work!PhotoSkitchDocument.png!

Doesn't work!Photo%20Skitch%20Document.png!

Works!/attachments/download/12345/Photo%20Skitch%20Document.png!
To get this last example to work, you need to grab the full url from the uploaded image, which is why I created the Redmine jsToolbar Images
Extension to figure this out automatically.
#18 - 2014-09-12 05:11 - Toshi MARUYAMA- 次のチケットが重複 Defect #17679: Attached inline image not working を追加#19 - 2014-09-13 05:29 - Toshi MARUYAMA- 関連している Defect #10182: UTF and Attachments を追加#20 - 2014-09-13 05:32 - Toshi MARUYAMA- 次のチケットが重複 Defect #13375: Inline Image formatting does not allow a file name with spaces を追加#21 - 2015-12-04 09:23 - Laurent Girard+1#22 - 2016-04-13 16:34 - Inese Ez

2024-09-27

4/5

+1
#23 - 2016-06-28 19:25 - Fernando Hartmann+1#24 - 2016-07-05 06:14 - Toshi MARUYAMA- カテゴリ を Wiki から Text formatting に変更#25 - 2016-11-04 05:44 - Stephane Lapie+1#26 - 2016-11-17 08:55 - Jose Mari M+1#27 - 2017-06-22 16:06 - Toshi MARUYAMA- 関連している Feature #26071: Generate markup for uploaded image dropped into wiki-edit textarea を追加#28 - 2022-08-22 13:04 - Mischka Lebensland
On Redmine 4.0:

Doesn't work!Photo

SkitchDocument.png!

Works!Photo%20Skitch%20Document.png!
#29 - 2023-05-13 10:32 - Andreas Baumgärtner+1
redmine 5.0.0
not working yet!somehelpful

picture.png!

workaround confirmed!some%20helpful%20picture.png!

ファイル
Sample Image.png
SampleImage2.png

10.6 KB

2012-02-09

Jason Palmer

10 KB

2012-02-09

Jason Palmer

space̲in̲inline̲image̲filename.patch

777 Bytes

2012-11-19

Dicky Hadiyuwono

unescape̲inline̲attachment̲filename.patch

465 Bytes

2013-12-03

Jeff Fendley

images̲with̲space.patch

909 Bytes

2013-12-15

Paulo Neves2024-09-27

5/5