fixed showing pdfs to download and not allowing in future

This commit is contained in:
Luca Haid
2025-09-01 14:07:59 +02:00
parent 771ad058ab
commit 80470bf9bd
2 changed files with 9 additions and 5 deletions

View File

@@ -212,10 +212,14 @@ $pagination_entity_name = "Adressen";
</tr><tr>
<th>Plan/Skizze</th>
<td>
<?php if($item->file && $item->file->file && $item->file->file->fileExists()): ?>
<!--img src="<?=self::getUrl("File", "Download", ["id" => $item->file->file_id])?>" style="max-width: 480px;"/-->
<img src="<?=$item->file->file->asDataUrl()?>" style="max-width: 480px;" />
<?php endif; ?>
<?php if($item->file && $item->file->file && $item->file->file->fileExists()):
$dataUrl = $item->file->file->asDataUrl();
if (str_contains($dataUrl, 'application/pdf')) {
echo '<a href="' . $dataUrl . '" download="your-file-name.pdf" class="btn btn-primary" aria-label="Download PDF"><i class="fas fa-download"></i> Download PDF</a>';
} else {
echo '<img src="' . $dataUrl . '" style="max-width: 480px;" alt="File preview"/>';
}
endif; ?>
</td>
</tr><tr>
<th></th>