Skip to content

Firefly III: a personal finances manager

Icons for attachments.

James Colef12dfc8a145c
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index d7a0722d14..225df6dcdd 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -36,7 +36,8 @@ class General extends Twig_Extension
$this->formatJournal(),
$this->balance(),
$this->getAccountRole(),
- $this->formatFilesize()
+ $this->formatFilesize(),
+ $this->mimeIcon(),
];
}
@@ -88,6 +89,26 @@ class General extends Twig_Extension
);
}
+ /**
+ * @return Twig_SimpleFilter
+ */
+ protected function mimeIcon()
+ {
+ return new Twig_SimpleFilter(
+ 'mimeIcon', function ($string) {
+ switch ($string) {
+ default:
+ return 'fa-file-o';
+ case 'application/pdf':
+ return 'fa-file-pdf-o';
+ case 'image/png':
+ case 'image/jpeg':
+ return 'fa-file-image-o';
+ }
+ }, ['is_safe' => ['html']]
+ );
+ }
+
/**
* @return Twig_SimpleFilter
*/
diff --git a/resources/twig/transactions/show.twig b/resources/twig/transactions/show.twig
index 095fa53220..3c5421b656 100644
--- a/resources/twig/transactions/show.twig
+++ b/resources/twig/transactions/show.twig
@@ -92,7 +92,7 @@
</div>
</td>
<td>
- <i class="fa fa-file-pdf-o"></i>
+ <i class="fa {{ att.mime|mimeIcon }}"></i>
<a href="{{ route('attachment.download', att.id) }}" title="{{ att.filename }}">
{% if att.title %}
{{ att.title }}