Add lightbox to image attachments

Moderator: crythias

Locked
shining01
Znuny expert
Posts: 270
Joined: 07 Apr 2011, 08:02
Znuny Version: 6.0.4
Real Name: Tom

Add lightbox to image attachments

Post by shining01 »

Hello,

my lightbox integration (per: viewtopic.php?f=62&t=24160) don't work. What is wrong? I can't get a preview of my gif Attachement. Thanks!

1. i copied the lightbox directory to C:\OTRS\var\httpd\htdocs\js\thirdparty\lightbox2.6
2. i added code to HTMLHead.dtl at the end

Code: Select all

   
<script src ="$Config{"Frontend::WebPath"}js/thirdparty/lightbox2.6/js/jquery-1.10.2.min.js"></script>
<script src ="$Config{"Frontend::WebPath"}js/thirdparty/lightbox2.6/js/lightbox-2.6.min.js"></script>
<link href="$Config{"Frontend::WebPath"}js/thirdparty/lightbox2.6/css/lightbox.css" rel="stylesheet" />		
</head>
3. i replaced code in c:\OTRS\Kernel\Output\HTML\ArticleAttachmentDownload.pm

Code: Select all

# --
# Kernel/Output/HTML/ArticleAttachmentDownload.pm
# Copyright (C) 2001-2013 xxx, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Output::HTML::ArticleAttachmentDownload;

use strict;
use warnings;

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    # get needed objects
    for (qw(ConfigObject LogObject DBObject LayoutObject UserID TicketObject ArticleID)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }
    return $Self;
}

sub Run {
    my ( $Self, %Param ) = @_;

    # check needed stuff
    for (qw(File Article)) {
        if ( !$Param{$_} ) {
            $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
            return;
        }
    }

    # download type	
[color=#FF0000]    my $EncodedFilename = $Self->{LayoutObject}->LinkEncode( $Param{File}->{Filename} || '' );

    my $rel = '';
    if (lc $EncodedFilename =~ /\.(tif|jpg|png|gif|jpeg|tiff)$/) {
       $rel = '" rel="lightbox';
    }
    return (
        %{ $Param{File} },
        Action => 'Download',
        Link =>
            "\$Env{\"CGIHandle\"}/$EncodedFilename?Action=AgentTicketAttachment;ArticleID=$Param{Article}->{ArticleID};FileID=$Param{File}->{FileID}" . $rel,[/color]
    );
}
1;
Last edited by crythias on 25 Feb 2014, 18:37, edited 1 time in total.
Reason: HowTos not for questions. Post moved to new topic
Linux Debian Jessie
DB: postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Add lightbox to image attachments

Post by crythias »

Does anything work? Any errors in Javascript Console? Any other errors?
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Locked