Opened 13 years ago

Last modified 13 years ago

#8466 closed defect

wiki.getPageHTML on page with image returns empty image — at Version 3

Reported by: ruidc@… Owned by: osimons
Priority: high Component: XmlRpcPlugin
Severity: major Keywords: image url wiki_to_html
Cc: Trac Release: 0.12

Description (last modified by Ryan J Ollos)

Image attached to page as [[Image(tab1.JPG)]] is fine in wiki, but calling getPageHTML returns empty tag: <img />

Trac v0.12.1
TracXMLRPC v1.1.0

Change History (3)

comment:1 Changed 13 years ago by ruidc@…

Forgot to mention, getPage returns [[Image(tab1.JPG)]] correctly.

comment:2 Changed 13 years ago by ruidc@…

Keywords: url wiki_to_html added

The following patch fixes it for me (thx to comment from t:#9292).

NB: that according to the trac source, wiki_to_html has been deprecated and format_to_html should be used instead.

  • wiki.py

    a b  
    1414from trac.resource import Resource, ResourceNotFound
    1515from trac.wiki.api import WikiSystem
    1616from trac.wiki.model import WikiPage
    17 from trac.wiki.formatter import wiki_to_html
     17from trac.wiki.formatter import wiki_to_html, format_to_html
     18from trac.mimeview import Context
    1819
    1920from tracrpc.api import IXMLRPCHandler, expose_rpc, Binary
    2021from tracrpc.util import StringIO, to_utimestamp, from_utimestamp
     
    9495    def getPageHTML(self, req, pagename, version=None):
    9596        """ Return page in rendered HTML, latest version. """
    9697        text = self.getPage(req, pagename, version)
    97         html = wiki_to_html(text, self.env, req, absurls=1)
     98        #html = wiki_to_html(text, self.env, req, absurls=1)
     99        resource = Resource('wiki', pagename)
     100        context = Context.from_request(req, resource, absurls=1)
     101        html = format_to_html(self.env, context, text)
    98102        return '<html><body>%s</body></html>' % html
    99103
    100104    def getAllPages(self, req):

comment:3 Changed 13 years ago by Ryan J Ollos

Description: modified (diff)
Note: See TracTickets for help on using tickets.