Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#6403 closed defect (fixed)

Preview feature is broken: inlined images are missing

Reported by: Emmanuel Blot Owned by: osimons
Priority: normal Milestone: 0.11
Component: attachment Version: devel
Severity: major Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Emmanuel Blot)

Using Trac 0.11dev-r6230

When a wiki page contains some [[Image()]] macros, the image links are invalid.
The resulting preview shows only the wiki text, with image placeholders - that actually depend on how the browser renders the missing image links.

It seems the error is due to the version management of the page:

  • In plain mode, image links are unversionned, such as in
    <img src="/project/raw-attachment/wiki/PageName/image.png" />
    
  • In preview/edit mode, image links are "versionned": the wiki page name part of the link contains the version of the page, such as in
    <img src="/project/raw-attachment/wiki/PageName%3Fversion%3D4/image.png" />
    

Attachments (0)

Change History (9)

comment:1 by Emmanuel Blot, 16 years ago

Description: modified (diff)
Summary: Preview feature is broken: inlined image are missingPreview feature is broken: inlined images are missing

comment:2 by osimons, 16 years ago

Component: wikiattachment

When building attachment support for my blog plugin, I noticed the same behavior. Understanding that the attachment module doesn't support versioned resources, I basically sent in resources with id=None.

Now, seeing this issue, it makes me think this is better resolved in the Attachment module - by having that strip off the version element when dealing with resources, particularly when constructing URLs as it uses the resource path as basis for path on disk.

There will be a lot of these resource descriptors flying around, so Attachment should handle them appropriately by never including ...?version=nn in filename. I certainly don't foresee us saving Attachments by both page and version, so ignoring version would be the easy alternative.

I can look into this if you like, as I think I pretty much know where and how. If so, just reassign it to me and I'll pick it up.

comment:3 by Christian Boos, 16 years ago

Maybe. But I think it's perhaps better in this case to fix the wiki preview as well, e.g.

  • trac/wiki/web_ui.py

    diff --git a/trac/wiki/web_ui.py b/trac/wiki/web_ui.py
    a b class WikiModule(Component):  
    132132                if action == 'edit' and not has_collision:
    133133                    self._do_save(req, versioned_page)
    134134                else:
    135                     return self._render_editor(req, versioned_page, action,
    136                                                has_collision)
     135                    return self._render_editor(req, page, action, has_collision)
    137136            elif action == 'delete':
    138137                self._do_delete(req, versioned_page)
    139138            elif action == 'diff':

in reply to:  3 comment:4 by Emmanuel Blot, 16 years ago

Replying to cboos:

Maybe. But I think it's perhaps better in this case to fix the wiki preview as well, e.g.

Agreed. As long as Trac is not able to manage versions of attached files, I don't see any reason to provide the versioned_page info.

osimons, I'm not sure if you were asking me or cboos to reassign the ticket. Feel free to get the ownership.

comment:5 by osimons, 16 years ago

Owner: changed from Christian Boos to osimons

Nothing wrong with the preview - except that is works with faulty data. This solves it as far as i can see.:

  • trac/attachment.py

     
    483483        if format == 'raw':
    484484            kwargs.pop('format')
    485485            prefix = 'raw-attachment'
    486         parent_href = get_resource_url(self.env, resource.parent, Href(''))
     486        parent_href = get_resource_url(self.env, resource.parent(version=None),
     487                                        Href(''))
    487488        if not resource.id:
    488489            return href(prefix, parent_href) + '/'
    489490        else:

comment:6 by osimons, 16 years ago

If solving this through attachment, #6375 is kind of related - showing problem with spaces and quoting (in addition to appending version as well).

comment:7 by Christian Boos, 16 years ago

Committed change in comment:3 in r6239. Simon, feel free to finish this ticket with the comment:5 change.

comment:8 by osimons, 16 years ago

Resolution: fixed
Status: newclosed

Committed comment:5 patch in [6241] (+ issue from #6375).

comment:9 by Emmanuel Blot, 16 years ago

Thanks, works smoothly.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain osimons.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from osimons to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.