meilleure prise en charge des images
This commit is contained in:
parent
c57b656380
commit
65cbe79f95
1 changed files with 22 additions and 2 deletions
24
js/ens.js
24
js/ens.js
|
@ -71,13 +71,33 @@ async function gen_contenu() {
|
||||||
let previewCell;
|
let previewCell;
|
||||||
let ext = doc.upload_path.toString().split(".").pop();
|
let ext = doc.upload_path.toString().split(".").pop();
|
||||||
|
|
||||||
|
let image_extensions = [
|
||||||
|
'jpg',
|
||||||
|
'jpeg',
|
||||||
|
'png',
|
||||||
|
'gif',
|
||||||
|
'bmp',
|
||||||
|
'tiff',
|
||||||
|
'tif',
|
||||||
|
'webp',
|
||||||
|
'svg',
|
||||||
|
'ico',
|
||||||
|
'raw'];
|
||||||
|
|
||||||
switch (ext) {
|
switch (ext) {
|
||||||
case "jpg": // image
|
case image_extensions.includes(ext): // image
|
||||||
previewCell = document.createElement('td');
|
previewCell = document.createElement('td');
|
||||||
const img = document.createElement('img');
|
const img = document.createElement('img');
|
||||||
img.src = doc.upload_path;
|
img.src = doc.upload_path;
|
||||||
img.alt = doc.titre;
|
img.alt = doc.titre;
|
||||||
previewCell.appendChild(img);
|
previewCell.appendChild(img);
|
||||||
|
|
||||||
|
let link = document.createElement('a');
|
||||||
|
link.href = doc.upload_path;
|
||||||
|
link.textContent = 'Voir image';
|
||||||
|
link.target = '_blank';
|
||||||
|
previewCell.appendChild(link);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "pdf": // pdf
|
case "pdf": // pdf
|
||||||
previewCell = document.createElement('td');
|
previewCell = document.createElement('td');
|
||||||
|
@ -104,7 +124,7 @@ async function gen_contenu() {
|
||||||
|
|
||||||
default :
|
default :
|
||||||
previewCell = document.createElement('td');
|
previewCell = document.createElement('td');
|
||||||
const link = document.createElement('a');
|
link = document.createElement('a');
|
||||||
link.href = doc.upload_path;
|
link.href = doc.upload_path;
|
||||||
link.textContent = 'Type de fichier non supporté.';
|
link.textContent = 'Type de fichier non supporté.';
|
||||||
link.target = '_blank';
|
link.target = '_blank';
|
||||||
|
|
Loading…
Reference in a new issue