Opened 10 years ago

Closed 5 years ago

# images from attachments don't work

Reported by: Owned by: rdeman anonymous normal CombineWikiPlugin normal broken image support attachements 0.10

### Description

when exporting Wiki pages that use images from attachements such as

[[Image(myImage.png)]]


then the PDF has no image but this error:

Error: Macro Image(myImage.png, left) failed
Cannot reference local attachment from here


### comment:1 Changed 10 years ago by Alec Thomas

Resolution: → invalid new → closed

What hack is this for exactly? Select the right component and reopen.

### comment:2 Changed 10 years ago by anonymous

Component: TracHacks → CombineWikiPlugin invalid closed → reopened

sorry: this is for CombineWiki. Also this applies to PageToPdf and PafeToOdt plugins.

### comment:3 Changed 10 years ago by Alec Thomas

Owner: changed from Alec Thomas to anonymous reopened → new

### Changed 10 years ago by drytoast

patch for attachment Image tag problems

### comment:4 Changed 10 years ago by drytoast

I've attached a diff of what I did to fix the problem for me. It adds an additional re object that runs over the page text similar the blacklist ones but it does an actual replacement rather than just removing stuff.

Basically, it will change any local attachment references [[Image(file.png)]] to include the wiki path leading up to it. This in turn allows the processor to find the attachment. It should skip Image tags that include a ':' in the name which means they already have some path information (needs to be full path to work) or are linked in htdocs or the like. I'm no python expert, there may be an better use of the re object but that is what I came up with.

### comment:5 Changed 10 years ago by drytoast

Also note, I only applied the regex in the PS/PDF output section. I haven't done anything with TiddlyWiki part though it should be a one liner. The HTML output doesn't have the same layout as the PDF stuff. It doesn't process any of the EXCLUDE_RES stuff, etc.

### comment:6 Changed 9 years ago by ice.polar@…

Hi there, is it possible thtat this fix also works on the Plugin PAGETOPDF? Couldn't find the lines in source but there must be a similar solution.

trac.log shows for each picture inserted with the [[image(pic.jpg)]] the following:

2008-12-22 23:00:03,432 Trac[pagetopdf] DEBUG: HTML output for PageToPDF in charset iso-8859-1
2008-12-22 23:00:03,453 Trac[api] DEBUG: Updating wiki page index
2008-12-22 23:00:03,548 Trac[formatter] DEBUG: Executing Wiki macro Image by provider <trac.wiki.macros.ImageMacro object at 0x8fba9ec>
2008-12-22 23:00:03,549 Trac[formatter] ERROR: Macro Image(Bild1.jpg) failed
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/wiki/formatter.py", line 470, in _macro_formatter
return macro.process(args, in_paragraph=True)
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/wiki/formatter.py", line 180, in process
text = self.processor(text)
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/wiki/formatter.py", line 167, in _macro_processor
text)
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/wiki/macros.py", line 425, in expand_macro
if attachment and 'ATTACHMENT_VIEW' in formatter.perm(attachment):
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/perm.py", line 523, in has_permission
return self._has_permission(action, resource)
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/perm.py", line 537, in _has_permission
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/perm.py", line 432, in check_permission
File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/resource.py", line 111, in __repr__
return '<Resource %r>' % (', '.join(reversed(path)))
TypeError: sequence item 0: expected string, NoneType found



Help apreciated, THX

Ice

### comment:7 Changed 5 years ago by Ryan J Ollos

Resolution: → wontfix new → closed