Is there a hack to append attached images to a ticket description?

50 views
Skip to first unread message

Aikido Guy

unread,
Nov 6, 2020, 2:26:03 PM11/6/20
to trac-hacks
Hi,

I did some searching but did not find what I'm looking for... maybe it does not (yet) exist; or maybe I'm not looking for the right thing.

Currently, someone creates a ticket and attaches one or more images (png, jpg, etc) to the ticket and then adds wiki markup [[Image(attachedFile.jpg)]] into the ticket's description. One ticket and one attached file at a time.

Ideally, in order to speed data entry up a bit, it would be nice that when somone creates a ticket and attaches one or more images to the ticket then the system automatically adds the necessary markup (to display the image) to the ticket's description. Avoiding the step of adding the necessary markup.

Is there such a plugin? If not, how could I start creating one?

Kindly,
Aikido Guy

Ryan Ollos

unread,
Nov 6, 2020, 4:55:27 PM11/6/20
to trac-hacks
This might help:
Each attachment has copyable Wiki markup for inserting the image. See last image on page.

Or this:
The Image macro is inserted into the ticket description when a file with extension jp[e]g, gif or png is added for upload.

Ryan 

Aikido Guy

unread,
Nov 10, 2020, 7:01:01 PM11/10/20
to trac-hacks
Interesting! Thanks ;) I see that it adds the Image macro on the client side... if I read correctly.

Is there a hook that I could use that would be like a "pre-render" for the ticket description? So I could add the image macro from the server side rather than client side? Not sure what the right interface might be to look at...

Ryan Ollos

unread,
Nov 10, 2020, 8:40:06 PM11/10/20
to trac-hacks
On Tuesday, November 10, 2020 at 4:01:01 PM UTC-8 aiki...@gmail.com wrote:
Interesting! Thanks ;) I see that it adds the Image macro on the client side... if I read correctly.

Is there a hook that I could use that would be like a "pre-render" for the ticket description? So I could add the image macro from the server side rather than client side? Not sure what the right interface might be to look at...

If you don't need access to the Request object, then IAttachmentChangeListener:

Otherwise IRequestFilter or IAttachmentManipulator:

I would guess you can probably do it in IAttachmentChangeListener without needing to access the requests object. The attachment.parent object will give you the ticket id and you can modify the Ticket description.

Ryan 
Reply all
Reply to author
Forward
0 new messages