Hide attachments for displayed inline images on tickets

Is there any way to hide the image attachments whitch are displayed inline in rt tickets?

Thx

I have a dirty patch for this (used for ages on prod systems):

diff --git a/rt/share/html/Ticket/Elements/ShowAttachments b/rt/share/html/Ticket/Elements/ShowAttachments
index 646d93a..9ec9e8b 100644
--- a/rt/share/html/Ticket/Elements/ShowAttachments
+++ b/rt/share/html/Ticket/Elements/ShowAttachments
@@ -145,6 +145,14 @@ $Attachments->OrderByCols(
 );

 while ( my $attach = $Attachments->Next() ) {
+   # Don't show inline attachments already displayed in ticket history (mostly
+   # part of signatures)
+   # FIXME we may also limit on the fact that this attachments should be a part
+   # of a multipart/related parent, but it's going to be really slow
+   my $content_disposition  = $attach->GetHeader('Content-Disposition');
+   next if ( RT->Config->Get('ShowTransactionImages') && $content_disposition =~ m/inline/ && $attach->GetHeader('Content-ID') );
+   # Do not show disclaimers as attachments
+   next if ( $content_disposition =~ m/inline/ && $attach->ContentType eq 'text/plain' );
    # display "show more" only when there will be more attachments
    if (defined($Count) && --$Count < 0) {
        $show_more = 1;
1 Like

Wow thx for this… But it seems not to work on RT 4.4.1. Whitch version are you using?

4.4.3, but it should be very close on 4.4.1, just copy/paste the needed lines manually?

hmm yes I did this are the last lines of my ShowAttachments file:

show newest first

$Attachments->OrderByCols(
);

{ FIELD => ‘Created’, ORDER => ‘DESC’ },

{ FIELD => ‘id’, ORDER => ‘DESC’ },

while ( my $attach = $Attachments->Next() ) {

Don’t show inline attachments already displayed in ticket history (mostly

part of signatures)

FIXME we may also limit on the fact that this attachments should bea part

of a multipart/related parent, but it’s going to be really slow

my $content_disposition = $attach->GetHeader(‘Content-Disposition’);
next if ( RT->Config->Get(‘ShowTransactionImages’) && $content_disposition =~ m/inline/ && $attach->GetHeader(‘Content-ID’) );

Do not show disclaimers as attachments

next if ( $content_disposition =~ m/inline/ && $attach->ContentType eq ‘text/plain’ );

display “show more” only when there will be more attachments

if (defined($Count) && --$Count < 0) {
$show_more = 1;
last;
}
push @{ $documents{ $attach->Filename } }, $attach;
}

my %is_checked = map { $_ => 1 } @Checked;

return if !$show_more && keys %documents == 0;
</%INIT>
<%ARGS>
$Ticket => undef
$Attachments => undef
$DisplayPath => $session{‘CurrentUser’}->Privileged ? ‘Ticket’ : ‘SelfService’
$HideTitleBox => 0
$Selectable => 0
$Count => undef
@Checked => ()
</%ARGS>

I have also restarted apache, cleared mason cache, rebooted the server …

Sorry, I misread your request, my patch is for hidden attachments in the ticket attachments box if they are already displayed in the ticket history (such as mail signatures images).

For your needs, you have to edit share/html/Elements/ShowTransactionAttachments and comment:
$m->out('<p><i>'. loc( 'Image displayed inline above' ) .'</i></p>');

with a “#”, then cleanup mason cache and restart fcgi process.

Thanky you Elacour that sort of works it removes the text … But can we also remove the download section?

Yes, maybe you have to filter them out in the foreach at the beginning of ShowTransactionAttachments, maybe by testing if already displayed with something like:

next if ( $displayed_inline->{$message->Id} );

?

Well so far I figured out if I comment out these lines in ShowTransactionAttachments:

elsif ( $displayed_inline->{$message->Id} ) {

$m->out(’

’. loc( ‘Image displayed inline above’ ) .’

’);

return;

}

Then instead of the text ShowTransactionAttachments it show the images whitch is kind of better. I am not a programer so any help with the code to hide / remove the download buttons for the inline images would be great … :wink: