i also cant make it work.

whats wrong?

For those that can not get it to work.

The zip file did not contain the file "jquery.js"

But you can link to the one on google api site.

https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js(https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js)

like so

<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.js"></script>

<script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>

<script type="text/javascript">

$(function() {

// Add the link classes that you would like to use with lightbox.

$('a.lightbox').lightBox();

});

</script>

Or just copy jquery.js into the JS folder from somewhere.

Hope this helps

Peter

6 days later

This helped indeed.

Sweet. Thank you very much.

a year later

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>&nbsp;(<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 :

blank

blank

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

attachments.jpg

zoom attachment.jpg

a month later

Hi :)

Any idea for client image view ?

Thanks :)

8 days later

Issue with path

I tried the mod here:

http://www.openscriptsolution.com/ticket-system/osticket/viewing-image-attachment-in-osticket-v1-6-rc5(http://www.openscriptsolution.com/ticket-system/osticket/viewing-image-attachment-in-osticket-v1-6-rc5)

My issue came up with the path not auto detecting. What happened was when I tested two tickets, the uploaded files ended up in my attachment path with /0213 folder inside, then the attachments.

So I had to edit the script:

$fullfilename = $helpdesk_url.$dir.'/0213'.$key.'_'.$name;

I don't know what the 0213 folder is and if it will change periodically or not.

5 months later

Also in 1.7

Hi!

Is there also an implementation in ver 1.7 possible?

Thanks in advance...

Greetings, Syn

3 months later

This is my solution for the file name issue. It was using the already existing function getCreateDate().

Sorry this text editor is screwing with me. 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 = $arrDir0;

$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)){

$hash=MD5($this->getId()*$refid.session_id());

$size=Format:($size);

$ext = strtolower(substr(strrchr($name, '.'), 1));

//Get month for filename path

$month=date('my',strtotime($this->getCreateDate()));

$ext = strtolower(substr(strrchr($name, '.'), 1));

//Insert .$month. for correct full filename.

$fullfilename = $helpdesk_url.$dir.''.$month.''.$key.'_'.$name;

if (in_array($ext,array('jpg', 'png', 'gif', 'bmp'))) {

list($width, $height, $type, $attr) = getimagesize($fullfilename);

if ($width > 820) {

$attachstr.= '

';

} else {

$attachstr.= '

';

}

}

$attachstr.= "$name ()  ";

}

}

return ($attachstr);

}

8 years later

I can't find this function getAttachmentStr neihter in includes/class.ticket.php nor any other folder. Any idea?

I am using v1.14.1

This thread is from 2008, and was last updated in 2013.
1.7 didn't have the getAttachmentStr() so it stands to reason that this was a function that ended between 1.6 to 1.7.

Write a Reply...