Skip to content
Aaron edited this page May 13, 2016 · 4 revisions

Welcome to the attachment_preview wiki!

How to use:

OK, so the main plugin itself is pretty "self-explanatory".. right?

You install it, you say who can use it, you say what they can preview inline. Using the admin interface for the plugin:

Configuring plugin

After that, whenever someone attaches something to a ticket that could be inlined into an HTML page, the plugin rewrites the html to include it. Why make agents download a PDF if they can just read it live in their browser. Also, it means you don't even need a PDF reader installed on most machines (that have chrome/firefox, IE is still special). Works for old tickets and should work for all storage systems.

That's it. It works now.

Just want the API ?

Simplicity itself, you "Enable" the plugin, then disable all access, done. API still functions, but it won't make any changes itself. (Read the code, with zero access, it's primary job is to return the raw HTML in full, eg).

To use the API? Read More

How it works

  • Essentially it's simple, when enabled, and a ticket page is viewed, an output buffer is created on osTicket BootStrap which waits for the page to be finished rendering by osTicket. (Using php's register_shutdown_function & ob_start)
  • When that's done, we fetch the output buffer and convert the HTML structure into a DOMDocument, pretty standard PHP so far.
  • The plugin then runs through the link elements of the Document, to find all Attachments.
  • It then adds a new DOMElement after the attachments section, inlining each attachment. PDF's become <object>'s, PNG's become <img> etc. Tested and works on 1.8-git. SHOULD work on future versions, depending on how the files are attached.. haven't tested on anything else though, let me know!

The plugin is self-contained, so ZERO MODS to core are required. You simply clone the repo or download the zip from github and extract into /includes/plugins/ which should make a folder: "attachment_preview", but it could be called anything.