Skip to content

Commit

Permalink
Fix attachment view, add attachment size
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflyfree committed Jan 22, 2024
1 parent 76ee8ee commit 82e3f04
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions system/modules/file/models/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ public function getMimetype(): string
return $this->mimetype;
}

/**
* Returns size of attachment in human readable format
*
* @return string size
*/
public function getSize(): string
{
return humanReadableBytes($this->getFile()->getSize());
}

/**
* Returns Gaufrette File instance (of the attached file)
*
Expand Down
16 changes: 12 additions & 4 deletions system/modules/file/partials/templates/attachment_item.tpl.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="image-container attachment text-center">
<div class="image-container-overlay">
<div class="row-fluid">
<button href="#" data-reveal-id="attachment_modal_<?php echo $attachment->id; ?>" class="button expand" onclick="$('#img_<?php echo $attachment->id; ?>').attr('src', $('#img_<?php echo $attachment->id; ?>').attr('src-async'));">
<button href="#" class="button expand" onclick="$('#img_<?php echo $attachment->id; ?>').attr('src', $('#img_<?php echo $attachment->id; ?>').attr('src-async')); $('#attachment_modal_<?php echo $attachment->id; ?>').foundation('reveal', 'open')">
View
</button>
</div>
Expand All @@ -24,19 +24,27 @@
<i class="fi-page" style="font-size: 90pt;"></i>
<?php } ?>
</div>
<a href="#" data-reveal-id="attachment_modal_<?php echo $attachment->id; ?>">
<a href="#" onclick="$('#img_<?php echo $attachment->id; ?>').attr('src', $('#img_<?php echo $attachment->id; ?>').attr('src-async')); $('#attachment_modal_<?php echo $attachment->id; ?>').foundation('reveal', 'open')">
<div class="row-fluid clearfix text-center" style="overflow: hidden;">
<b>Title: </b><?php echo $attachment->title; ?>
<b>Title: </b><?php echo $attachment->filename; ?>
</div>
<div class="row-fluid clearfix text-center" style="overflow: hidden;">
<b>Description: </b><?php echo strip_tags($attachment->description ?? ""); ?>
<?php
$description = strip_tags($attachment->description ?? "");
if($description !== "") {
echo '<b>Description: </b>' . $description;
}
?>
</div>
<div class="row-fluid clearfix text-center">
<?php if (!empty($owner)) {
$contact = $owner->getContact();
$buffer .= empty($contact) ? "" : "<b>Owner: </b> " . $contact->getFullname();
} ?>
</div>
<div class="row-fluid clearfix text-center" style="overflow: hidden;">
(<?php echo $attachment->getSize(); ?>)
</div>
</a>
<div id="attachment_modal_<?php echo $attachment->id; ?>" class="reveal-modal file__pdf-modal" data-reveal role="dialog">
<div class="row-fluid panel" style="text-align: center;">
Expand Down

0 comments on commit 82e3f04

Please sign in to comment.