Add default pictures where no image uploaded for products

This commit is contained in:
poka 2019-11-25 20:17:45 +01:00
parent f3728dd939
commit 5b3332b798
4 changed files with 19 additions and 8 deletions

3
.gitignore vendored
View File

@ -1,7 +1,8 @@
config/config.php
scripts/.loc_hash
.idea
/public/uploads
public/uploads/*
!public/uploads/default.png
/tmp
vendor
composer.json

View File

@ -63,7 +63,12 @@
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
$cle_pub_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/api/#/v1/payment/$pubkey?amount=$prix&name=$vendeur&comment=[Achat GMarche] : $produit&preferred_node=https://g1.librelois.fr&redirect_url=https://gmarche.monnaie-libre.fr\" title=$pubkey> $pubkeyShort... </a>";
$data .= '<td>'.$produit.'</td>';
$data .= '<td><img src="/uploads/products/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
$imagep = '../uploads/products/'.$antenne_slug.'/'.$row['image'].'';
if (file_exists($imagep) && $row['image']) {
$data .= '<td><img src="/uploads/products/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
} else {
$data .= '<td><img src="/uploads/default.png" width="50" height="50" /></td>';
}
$data .= '<td>'.$vendeur_format.'</td>';
$data .= '<td>'.$cle_pub_format.'</td>';
$data .= '<td>'.$quantite.'</td>';

View File

@ -19,11 +19,11 @@
$params["antenne_slug"] = $antenne_slug;
$requete = "SELECT souhaits.*, users.username, users.pubkey
FROM souhaits
LEFT JOIN antennes
ON antennes.id = souhaits.antenne_id
LEFT JOIN users
ON users.id = souhaits.user_id
FROM souhaits
LEFT JOIN antennes
ON antennes.id = souhaits.antenne_id
LEFT JOIN users
ON users.id = souhaits.user_id
WHERE antennes.slug = :antenne_slug";
$stmt = $bdd->prepare($requete);
$stmt2 = $bdd->prepare($requete);
@ -55,7 +55,12 @@
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
$pubkeyShort = substr($pubkey, 0, 8);
$data .= '<td>'.$produit.'</td>';
$data .= '<td><img src="/uploads/recherches/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
$imagep = '../uploads/recherches/'.$antenne_slug.'/'.$row['image'].'';
if (file_exists($imagep) && $row['image']) {
$data .= '<td><img src="/uploads/recherches/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
} else {
$data .= '<td><img src="/uploads/default.png" width="50" height="50" /></td>';
}
$data .= '<td>'.$vendeur_format.'</td>';
$data .= '<td>'.$pubkeyShort.'...</td>';
$data .= '<td>'.$row['quantite'].'</td>';

BIN
public/uploads/default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB