Modify

Opened 7 years ago

Closed 2 years ago

#1738 closed defect (wontfix)

images from attachments don't work

Reported by: coenen.rob@… Owned by:
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 7 years ago.
patch for attachment Image tag problems

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by athomas

  • Resolution set to invalid
  • Status changed from new to closed

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

comment:2 Changed 7 years ago by anonymous

  • Component changed from TracHacks to CombineWikiPlugin
  • Resolution invalid deleted
  • Status changed from closed to reopened

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

comment:3 Changed 7 years ago by athomas

  • Owner athomas deleted
  • Status changed from reopened to new

Changed 7 years ago by drytoast

patch for attachment Image tag problems

comment:4 Changed 7 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 7 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 6 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 2 years ago by rjollos

  • Resolution set to wontfix
  • Status changed from new to closed

Deprecated: Please try the TracWikiToPdfPlugin.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.