feat: add image rendering in file display template

This commit is contained in:
Jan Klattenhoff 2024-12-21 17:11:01 +01:00
parent 54bcfd3775
commit 987e49cdec
2 changed files with 6 additions and 2 deletions

View File

@ -26,7 +26,7 @@ readonly class DirContent
$fileInfo->getType() ?? 'N/A',
$fileInfo->getPath(),
$content,
mime_content_type($fileInfo->getFilename()),
mime_content_type($fileInfo->getPath() . '/' . $fileInfo->getFilename()),
);
}

View File

@ -15,7 +15,11 @@
</a>
<div class="mt-6 text-gray-700 overflow-auto max-h-96">
<p class="whitespace-pre-wrap leading-relaxed break-all text-balance">{{ file.content|raw }}</p>
{% if file.mimeType starts with 'image' %}
<img src="{{ path('serve_file', {filePath: file.name}) }}" alt="">
{% else %}
<p class="whitespace-pre-wrap leading-relaxed break-all text-balance">{{ file.content|raw }}</p>
{% endif %}
</div>
</div>
{% endblock %}