Lightbox and date on folder issue
@[deleted]
Here is the code with the date issue resolved. I also added the "lightbox" class to the URL to have the images pop up in a lightbox rather than a blank page. If you want them to appear in a blank page just add the "target=_blank" to the URL.
// Modified by Masino Sinaga, last updated: November 5, 2009
// in order to display image properly inside the ticket area
// especially if the image's width greater than 820 px, then
// resize the image's width maximum to 820 px.
//Ed Barahona Ed@newmediahaus.com 10/28/2011 updates:
//Fixed the Date issue with URlS
//Added JQuery-lightbox class to URL's
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 = $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.= '<p align="center"><a class="lightbox" href="'.$fullfilename.'"><IMG alt="blank" src="js/jquery.js"></IMG></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>
You will also need to download the jquery lightbox folder that I've attached. Drop the files in their corresponding folders in the SCP directory (images in the image folder, .js in the js folder and .css in the css folder).
[Jqery_lightbox.zip](https://forum.osticket.com/assets/files/migrated/e/70f0563b3b7fba41ab0f59f218c5e8a.zip)