Hi all :)
I wanted to display attached images in the ticket thread so I tried the differents codes above and the result was not totally good for me.
For example, wrong URL of the attachment, lightbox was not running, file name at the left.
So I search for get these problems fixed and here is the code I finally got :
In include/class.ticket.php :
function getAttachmentStr($refid,$type){
global $cfg;
$helpdesk_url=$cfg->getUrl();
$dir=$cfg->getUploadDir();
$dir = preg_replace("/\\\\/","/",$dir);
$dir = explode('/', $dir);
$arrDir = array_reverse($dir);
$dir = $arrDir;
$sql ='SELECT attach_id,file_size,file_name,file_key FROM '.TICKET_ATTACHMENT_TABLE.
' WHERE deleted=0 AND ticket_id='.db_input($this->getId()).' AND ref_id='.db_input($refid).' AND ref_type='.db_input($type);
$res=db_query($sql);
if($res && db_num_rows($res)){
while(list($id,$size,$name,$key)=db_fetch_row($res)){
$month=date('my',strtotime($this->getCreateDate()));
$hash=MD5($this->getId()*$refid.session_id());
$size=Format:($size);
$ext = strtolower(substr(strrchr($name, '.'), 1));
$fullfilename = '../'.$dir.'/'.$month.'/'.$key.'_'.$name;
$attachstr.= "<p align=center><a class='Icon file' href='attachment.php?id=$id&ref=$hash'><b>$name</b></a> (<i>$size</i>)</p>";
if (in_array($ext,array('jpg', 'png', 'gif', 'bmp'))) {
list($width, $height, $type, $attr) = getimagesize($fullfilename);
if ($width > 100) {
$attachstr.= '<div id="gallery"><p align="center"><a href="'.$fullfilename.'"><IMG alt="blank" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js"></IMG></script>
<script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<script type="text/javascript">
$(function() {
$('#gallery a').lightBox();
});
</script>
And placed jquery files in the /scp/ folder (and of course, js, css, images subfolders).
And here is the nice result :


But I would get the same feature for ticket client view, but I get only file names, without thumbs. I don't understand because it seems to use the same class.ticket configuration file. So perhaps there is a rule to display images (like if User=Staff display=yes ) , but I don't find it.
Also, I would have the file name written centered under the lightboxed window (between Image x of y and Close X) , but the codes I tried to had was breaking the site lol
If some one have an idea :)
Thanks
Couin

