Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

[MOD] In-Line Preview of attached PDF with Rotate Function!

This creates an almost full-size preview of attached PDF's and then inserts them into the HTML of the ticket thread as a JPG, for Staff only.
It also generates a little jQuery script for the image so staff can rotate it 180 degrees.. because Faxes.. damn machines still get users confused and they sometimes send them upside down. This lets the image-preview rotate 180 degrees.

Dunno if anyone but me would find it useful, let me know what you think.

Requirements: ImageMagick on the server, php-imagick not required. Currently works only on Linux, might be easy to rewrite for Windows, don't have one to try.


[*]Edit scp.css add: (just right at the bottom is fine)
.rotated {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
-moz-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);

[*]Save attachments_thumbnailer.php into /include/
[*]Edit include/class.thread.php: (Round line 458)

function getAttachmentsLinks($file = 'attachment.php', $target = 
$size = sprintf('<em>(%s)</em>', Format :: file_size($attachment['size']));
include('attachments_thumbnailer.php'); //___________________________add this line here___________________________________
$str .= sprintf('<a class=\"Icon file\"...

[*]Edit attachments_thumbnailer.php and choose your settings.
  • At the very least, you will need to set the Base URL, change ''; into whatever your scp base URL is.
  • You can also adjust the image quality by modifying the $imageMagickCommand, read more here
  • $showInLogs = false; Change to true to show actions performed in the apache error logs.

Works on attachments saved in your database, until the API is changed!

To ensure your hard-drive isn't exhausted by doubling up with a preview of all these thumbnails, simply create a crontask that will empty old attachments from the folder:
find /path/to/scp/restricted -type f -mtime +7 -delete

Users rarely need old attachments, and it will simply regenerate as required anyway!


Sign In or Register to comment.