Modify

Opened 17 years ago

Closed 12 years ago

#1738 closed defect (wontfix)

images from attachments don't work

Reported by: rdeman Owned by: anonymous
Priority: normal Component: CombineWikiPlugin
Severity: normal Keywords: broken image support attachements
Cc: Trac Release: 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

Attachments (1)

formats.diff (676 bytes) - added by drytoast 17 years ago.
patch for attachment Image tag problems

Download all attachments as: .zip

Change History (8)

comment:1 Changed 17 years ago by Alec Thomas

Resolution: invalid
Status: newclosed

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

comment:2 Changed 17 years ago by anonymous

Component: TracHacksCombineWikiPlugin
Resolution: invalid
Status: closedreopened

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

comment:3 Changed 17 years ago by Alec Thomas

Owner: changed from Alec Thomas to anonymous
Status: reopenednew

Changed 17 years ago by drytoast

Attachment: formats.diff added

patch for attachment Image tag problems

comment:4 Changed 17 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 17 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 16 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
    check_permission(action, perm.username, resource, perm)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.2.1-py2.5.egg/trac/perm.py", line 432, in check_permission
    (username, action, resource))
  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 12 years ago by Ryan J Ollos

Resolution: wontfix
Status: newclosed

Deprecated: Please try the TracWikiToPdfPlugin.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anonymous.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.