Skip to content

Commit

Permalink
Espace membre : affichage d'une miniature des images possédées en gri…
Browse files Browse the repository at this point in the history
…lle.

Génération automatique de la miniature si non existante
  • Loading branch information
AnaelMobilia committed Dec 20, 2021
1 parent cdf84b6 commit aa6f0fc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 39 deletions.
3 changes: 3 additions & 0 deletions config/image-heberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ function exception_handler($exception)
define('_IMAGE_404_', '_image_404.png');
define('_IMAGE_BAN_', '_image_banned.png');

// Dimensions des apeçus dans l'espace membre
define('_SIZE_PREVIEW_', 256);

/**
* Tor
*/
Expand Down
92 changes: 53 additions & 39 deletions membre/mesImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
* along with image-heberg.fr. If not, see <http://www.gnu.org/licenses/>
*/

// TODO : affichage des images dans la page en javascript ?
// TODO : navigation entre les images

namespace ImageHeberg;

require __DIR__ . '/../config/config.php';
Expand All @@ -34,43 +31,60 @@

require _TPL_TOP_;
?>
<h1 class="mb-3"><small>Mes images</small></h1>
<table class="table table-hover">
<thead>
<tr class="text-center">
<th>Nom de l'image</th>
<th>Date d'envoi</th>
<th>Dernier affichage</th>
<th>Nb. vues</th>
<th>Voir</th>
<th>Supprimer</th>
</tr>
</thead>
<tbody>
<h1 class="mb-3"><small>Mes images</small></h1>
<div class="row">
<?php

$mesImages = $monUtilisateur->getImages();
foreach ((array) $mesImages as $newName) :
foreach ((array)$mesImages as $newName) :
$uneImage = new ImageObject($newName);
$miniature = $uneImage->getMiniatures(true);
if ($miniature->count() == 0) {
// Duplication de l'image source
$tmpFile = tempnam(sys_get_temp_dir(), uniqid());
copy($uneImage->getPathMd5(), $tmpFile);

// Génération de la miniature pour l'aperçu
$maMiniature = new MiniatureObject();
$maMiniature->setPathTemp($tmpFile);
$maMiniature->setIdImage($uneImage->getId());
$maMiniature->redimensionner($maMiniature->getPathTemp(), $maMiniature->getPathTemp(), _SIZE_PREVIEW_, _SIZE_PREVIEW_);
$maMiniature->setNomTemp("preview_" . $uneImage->getId());
$maMiniature->creer();
$maMiniature->setIsPreview(true);
$maMiniature->sauver();
} else {
$maMiniature = new MiniatureObject($miniature->offsetGet(0));
}
?>
<tr>
<td><?= $uneImage->getNomOriginalFormate() ?></td>
<td class="text-center"><?= $uneImage->getDateEnvoiFormatee() ?></td>
<td class="text-center"><?= $uneImage->getLastViewFormate() ?></td>
<td class="text-center"><?= $uneImage->getNbViewTotal() ?></td>
<td class="text-center">
<a href='<?= _URL_IMAGES_ ?><?= $uneImage->getNomNouveau() ?>' target="_blank">
<span class="fas fa-share-square"></span>
</a>
</td>
<td class="text-center">
<a href='<?= _URL_ ?>delete.php?id=<?= $uneImage->getNomNouveau() ?>&type=<?= RessourceObject::TYPE_IMAGE ?>'
target="_blank">
<span class="fas fa-trash"></span>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php require _TPL_BOTTOM_ ?>
<div class="col p-1" style="min-width: <?= _SIZE_PREVIEW_ ?>px;">
<div class="card h-100">
<div class="card-header">
<?= $uneImage->getNomOriginalFormate() ?>
</div>
<div class="card-body">
<p class="card-text">
Envoyée le <?= $uneImage->getDateEnvoiFormatee() ?>
<br/>
<?= $uneImage->getNbViewTotal() ?> affichages <span title="Date du dernier affichage" class="fw-light fst-italic">(<?= $uneImage->getLastViewFormate() ?>)</span>
</p>
</div>
<div class="text-center">
<img src="<?= $maMiniature->getURL() ?>" class="card-img-bottom rounded-3" alt="<?= $uneImage->getNomOriginalFormate() ?>" style="<?= ($maMiniature->getLargeur() < 256 ? "max-height: " . _SIZE_PREVIEW_ . "px; width: auto;" : "height: auto; max-width: " . _SIZE_PREVIEW_ . "px;") ?>">
</div>
<div class="card-footer text-muted text-end">
<span class="fas fa-edit"></span>
<span class="fas fa-link"></span>
<a href='<?= _URL_IMAGES_ ?><?= $uneImage->getNomNouveau() ?>' title="Afficher" target="_blank">
<span class="fas fa-search-plus"></span>
</a>
<a href='<?= _URL_ ?>delete.php?id=<?= $uneImage->getNomNouveau() ?>&type=<?= RessourceObject::TYPE_IMAGE ?>' title="Effacer" class="link-danger" target="_blank">
<span class="fas fa-trash"></span>
</a>
</div>
</div>
</div>
<?php
endforeach; ?>
</div>
<?php
require _TPL_BOTTOM_; ?>

0 comments on commit aa6f0fc

Please sign in to comment.