-réécriture du code pour l’image du mois et les vignettes
-simplication: $images_du_mois est un tableau qui rassemble les chemins SD et HD, les exifs pour toutes des les images de l’album *photo-du-mois* -utilisation de PDO pour les requêtes MySQL -utilisation de kk-lightbox comme Lightbox
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
$root = $_SERVER['DOCUMENT_ROOT'];
|
||||
define('SERVERPATH',$root.'/zenphoto');
|
||||
include('../photoblog/exifer/exif.php');
|
||||
require_once($_SERVER['DOCUMENT_ROOT'].'/Connections/cnx.php');
|
||||
|
||||
//nb d'archive par page
|
||||
$nb = 12;
|
||||
@@ -75,49 +76,51 @@ $bg_title_img = $kk_parallax[1];
|
||||
|
||||
<?php the_content (); ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$mois = date('n');
|
||||
$an = date('Y');
|
||||
$image = $mois . '_' . $an . '.jpg';
|
||||
$annee = $an;
|
||||
/*** Photos du mois ***/
|
||||
|
||||
$album = 'photos-du-mois'; //Photos du mois
|
||||
$images_du_mois = imagesFromZPAlbum($album, $connexion);
|
||||
|
||||
// nom des fichiers: 7_2009.jpg et non pas 07_2009.jpg
|
||||
|
||||
for ($i = 0; $i <= 11 ; $i++) {
|
||||
$a = ($mois - $i);
|
||||
if ($a < 1) {
|
||||
$a = (12 + $a);
|
||||
$annee = $an - 1;
|
||||
}
|
||||
$tableau[$i] = $a . '_' . $annee . '.jpg';
|
||||
}
|
||||
/*
|
||||
1_2018_40_cw40_ch40_thumb.jpg
|
||||
1_2018_80_cw80_ch80_thumb.jpg
|
||||
1_2018_200_thumb.jpg thumb WP SD
|
||||
1_2018_300_thumb.jpg
|
||||
1_2018_400_thumb.jpg thumb WP HD
|
||||
1_2018_800_clicclac.jpg image du mois SD
|
||||
1_2018_w1400_h550_thumb.jpg
|
||||
*/
|
||||
|
||||
$watermark = "_clicclac";
|
||||
$i = 0;
|
||||
while ($i < 13) {
|
||||
$file = '../zenphoto/albums/photos-du-mois/' . $tableau[$i];
|
||||
//echo $file;
|
||||
//$file = '../zenphoto/albums/photos-du-mois/' . $tableau[$i];
|
||||
$file = '../zenphoto/albums/photos-du-mois/' . $images_du_mois[$i]['filename'];
|
||||
//$file = 'https://silverbook.local/zenphoto/albums/photos-du-mois/' . $images_du_mois[$i]['filename'];
|
||||
|
||||
if (file_exists($file)) {
|
||||
$photo_du_mois = $file;
|
||||
$title = $tableau[$i];
|
||||
//$photo_du_mois = $file;
|
||||
//$title = $tableau[$i];
|
||||
$filename = $images_du_mois[$i]['filename'];
|
||||
|
||||
$size = getimagesize($photo_du_mois, $info);
|
||||
$size = getimagesize($file, $info);
|
||||
//preprint($size);
|
||||
|
||||
if ($size[0] > 1000) {
|
||||
// HD
|
||||
$hd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_FULL_watermark.jpg";
|
||||
//$hd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_FULL_watermark.jpg";
|
||||
$hd = $file;
|
||||
if (file_exists($hd)) {
|
||||
$size_hd = getimagesize($hd, $info_hd);
|
||||
$imgs['img_hd'] = array(
|
||||
'url' => $hd,
|
||||
'url' => "../" . $hd,
|
||||
'width' => $size_hd[0],
|
||||
'height' => $size_hd[1]
|
||||
);
|
||||
}
|
||||
/*
|
||||
else {
|
||||
$imgs['img_hd'] = array(
|
||||
'url' => '../' . $photo_du_mois,
|
||||
@@ -125,24 +128,29 @@ $bg_title_img = $kk_parallax[1];
|
||||
'height' => $size[1]
|
||||
);
|
||||
}
|
||||
*/
|
||||
// SD
|
||||
$sd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_800_watermark.jpg";
|
||||
|
||||
// 12_2017_800_clicclac.jpg
|
||||
|
||||
$sd = '../zenphoto/cache/photos-du-mois/' . substr($filename, 0, strlen($filename) - 4) . "_800" . $watermark . ".jpg";
|
||||
if (file_exists($sd)) {
|
||||
$size_sd = getimagesize($sd, $info_sd);
|
||||
$imgs['img_sd'] = array(
|
||||
'url' => $sd,
|
||||
'url' => "../" . $sd,
|
||||
'width' => $size_sd[0],
|
||||
'height' => $size_sd[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
// SD
|
||||
$sd = '../../zenphoto/cache/photos-du-mois/' . substr($tableau[$i], 0, strlen($tableau[$i]) - 4) . "_800_watermark.jpg";
|
||||
$sd = '../zenphoto/cache/photos-du-mois/' . substr($filename, 0, strlen($filename) - 4) . "_800" . $watermark . ".jpg";
|
||||
if (file_exists($sd)) {
|
||||
$size_sd = getimagesize($sd, $info_sd);
|
||||
$imgs['img_sd'] = array(
|
||||
'url' => $sd,
|
||||
'url' => "../" . $sd,
|
||||
'width' => $size_sd[0],
|
||||
'height' => $size_sd[1]
|
||||
);
|
||||
@@ -154,18 +162,57 @@ $bg_title_img = $kk_parallax[1];
|
||||
);
|
||||
} // if ($size[0] > 1000)
|
||||
|
||||
$title = explode('.',$title);
|
||||
$title = explode('_',$title[0]);
|
||||
$title = mois2($title[0]) . ' ' . $title[1];
|
||||
$imgs['img_sd']['title'] = $title;
|
||||
|
||||
foreach ($images_du_mois[$i] as $key => $val) {
|
||||
$imgs[$key] = $val;
|
||||
}
|
||||
|
||||
if (isset($info["APP13"])) {
|
||||
$iptc = iptcparse($info["APP13"]);
|
||||
// Ajouter les tags
|
||||
|
||||
// Présentation Title et Desc
|
||||
|
||||
//preprint($imgs);
|
||||
|
||||
if (isset($iptc['2#120'][0])) $legende = $iptc['2#120'][0];
|
||||
else $legende = "";
|
||||
if (isset($iptc['2#005'][0])) $titre = $iptc['2#005'][0];
|
||||
else $titre = "";
|
||||
/*
|
||||
Array
|
||||
(
|
||||
[img_hd] => Array
|
||||
(
|
||||
[url] => ../../zenphoto/albums/photos-du-mois/11_2018.jpg
|
||||
[width] => 1600
|
||||
[height] => 1067
|
||||
)
|
||||
|
||||
[img_sd] => Array
|
||||
(
|
||||
[url] => ../../zenphoto/cache/photos-du-mois/11_2018_800_clicclac.jpg
|
||||
[width] => 800
|
||||
[height] => 534
|
||||
)
|
||||
|
||||
[filename] => 11_2018.jpg
|
||||
[EXIFModel] => Canon EOS-1D Mark IV
|
||||
[EXIFDateTimeOriginal] => 2018:11:04 11:05:09
|
||||
[EXIFExposureTime] => 1/2000 sec
|
||||
[EXIFFNumber] => f/7,1
|
||||
[EXIFISOSpeedRatings] => 500
|
||||
[EXIFFocalLength] => 700 mm
|
||||
[EXIFLensInfo] => EF500mm f/4L IS USM +1.4x
|
||||
[EXIFGPSLatitude] =>
|
||||
[EXIFGPSLatitudeRef] =>
|
||||
[EXIFGPSLongitude] =>
|
||||
[EXIFGPSLongitudeRef] =>
|
||||
[EXIFGPSAltitude] =>
|
||||
[EXIFGPSAltitudeRef] =>
|
||||
[desc] =>
|
||||
[title] => 11_2018
|
||||
[exif] => Le 04.11.2018 à 11:05 - 1/2000 sec à f/7,1 - 500 ISO - Focale700 mm
|
||||
[exif+] => Canon EOS-1D Mark IV - EF500mm f/4L IS USM +1.4x
|
||||
[gps] =>
|
||||
)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
$keyword = "";
|
||||
if (isset($iptc['2#025'])) {
|
||||
@@ -176,23 +223,21 @@ $bg_title_img = $kk_parallax[1];
|
||||
$keyword = substr($keyword, 0, -2);
|
||||
}
|
||||
|
||||
$imgs['img_sd']['legende'] = $legende;
|
||||
$imgs['img_sd']['titre'] = $titre;
|
||||
$imgs['img_sd']['keyword'] = $keyword;
|
||||
}
|
||||
|
||||
$exifInfo = "";
|
||||
$exif_array = read_exif_data_raw($file,'EXIF');
|
||||
$exifInfo = __('The','toppic-child') . " " .date(__("F j, Y, g:i a",'toppic-child'),strtotime($exif_array['SubIFD']['DateTimeOriginal'])).' - ';
|
||||
$exifInfo .= $exif_array['SubIFD']['ExposureTime']. __(' at ','toppic-child') .$exif_array['SubIFD']['FNumber'].' - ' .$exif_array['SubIFD']['ISOSpeedRatings'].' ISO - '. __('Focal','toppic-child') .$exif_array['SubIFD']['FocalLength'];
|
||||
$imgs['img_sd']['exif'] = $exifInfo;
|
||||
*/
|
||||
|
||||
$exifInfo = "";
|
||||
$exifInfo = __('The','toppic-child') . " " .date(__("F j, Y, g:i a",'toppic-child'),strtotime($imgs['EXIFDateTimeOriginal'])).' - ';
|
||||
$exifInfo .= $imgs['EXIFExposureTime'] . __(' at ','toppic-child') . $imgs['EXIFFNumber'] .' - ' . $imgs['EXIFISOSpeedRatings'] .' ISO - ' . __('Focal','toppic-child') .$imgs['EXIFFocalLength'];
|
||||
$imgs['exif'] = $exifInfo;
|
||||
$imgs['exif+'] = $imgs['EXIFModel'] . ' - ' . $imgs['EXIFLensInfo'];
|
||||
$imgs['gps'] = '';
|
||||
|
||||
//preprint($exif_array);
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
//preprint($imgs);
|
||||
|
||||
?>
|
||||
|
||||
@@ -202,42 +247,28 @@ $bg_title_img = $kk_parallax[1];
|
||||
|
||||
<div class="cadre">
|
||||
|
||||
<?php if (($imgs['img_sd']['titre'] != "") || ($imgs['img_sd']['legende'] != "")) { ?>
|
||||
<p class="titrePhoto"><?php echo $imgs['img_sd']['titre']; ?>Titre</p>
|
||||
<p class="legendePhoto"><?php echo $imgs['img_sd']['legende']; ?>Légende</p>
|
||||
<?php } ?>
|
||||
<?php if (($imgs['title'] != "") || ($imgs['desc'] != "")) { ?>
|
||||
<p class="titrePhoto"><?php echo $imgs['title']; ?></p>
|
||||
<p class="legendePhoto"><?php echo $imgs['desc']; ?></p>
|
||||
<?php }
|
||||
|
||||
<!--img src="watermark2.php?src=<?php echo $photo_du_mois; ?>" alt="Image du mois" title="<?php echo $title; ?>" <?php echo $size[3]; ?> /-->
|
||||
|
||||
<!-- Retina -->
|
||||
<?php
|
||||
|
||||
if (($imgs['img_sd']['url'] != "") && ($imgs['img_hd']['url'] != "")) {
|
||||
$standard_source = $imgs['img_sd']['url'] . ', ' . $imgs['img_hd']['url'] . ' 2x';
|
||||
//echo "1";
|
||||
$standard_source = $imgs['img_sd']['url'] . ' 800w, ' . $imgs['img_hd']['url'] . ' 1600w';
|
||||
}
|
||||
else if ($imgs['img_sd']['url'] != "") {
|
||||
$standard_source = $imgs['img_sd']['url'];
|
||||
//echo "2";
|
||||
$standard_source = $imgs['img_sd']['url'] . ' 800w';
|
||||
}
|
||||
else if ($imgs['img_hd']['url'] != "") {
|
||||
$standard_source = $imgs['img_hd']['url'] . ' 2x';
|
||||
//echo "3";
|
||||
$standard_source = $imgs['img_hd']['url'] . ' 1600w';
|
||||
}
|
||||
//echo $standard_source;
|
||||
?>
|
||||
|
||||
<picture data-picture data-alt="">
|
||||
<!--[if IE 9]><video style="display: none;"><![endif]-->
|
||||
<source class="image_standard" srcset="<?php echo $standard_source; ?>">
|
||||
<!--source class="image_medium" srcset="" media="(max-width: 767px)">
|
||||
<source class="image_small" srcset="" media="(max-width: 767px)"-->
|
||||
<!--[if IE 9]></video><![endif]-->
|
||||
<?php
|
||||
echo '<img srcset="' . $imgs['img_sd']['url'] . '" alt="" width="'. $imgs['img_sd']['width'] . '" height="'. $imgs['img_sd']['height'] .'" />';
|
||||
?>
|
||||
</picture>
|
||||
|
||||
<!-- /Retina -->
|
||||
$display = '<a href="' . $imgs['img_hd']['url'] .'" title="'.$imgs['title'].'" class="kk-lightbox">';
|
||||
$display .= "<img width='" . $imgs['img_sd']['width'] . "' height='" . $impgs['img_sd']['height'] . "' src='" . $imgs['img_sd']['url'] . "' class='' alt='' srcset='" . $standard . "' sizes='(max-width: 800px) 100vw, 800px' />";
|
||||
$display .= '</a>';
|
||||
|
||||
echo $display;
|
||||
?>
|
||||
|
||||
</div><!-- /cadre -->
|
||||
|
||||
@@ -246,84 +277,13 @@ $bg_title_img = $kk_parallax[1];
|
||||
<p class="legendePhoto"><?php echo $imgs['img_sd']['legende']; ?>Légende</p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="exifs"><?php echo $imgs['img_sd']['exif']; ?></p>
|
||||
<p class="exifs"><?php echo $imgs['exif']; ?></p>
|
||||
|
||||
<!-- /image du mois -->
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'].'/Connections/cnx.php');
|
||||
|
||||
$album = 'photos-du-mois'; //Photos du mois
|
||||
$table = array();
|
||||
if ($_SERVER['HTTP_HOST'] == "silverbook.local") {
|
||||
$table['images'] = ".images";
|
||||
$table['albums'] = ".albums";
|
||||
}
|
||||
/*
|
||||
if ($_SERVER['HTTP_HOST'] == "clicclac.info") {
|
||||
$table['images'] = "zp_images";
|
||||
$table['albums'] = "zp_albums";
|
||||
}
|
||||
*/
|
||||
if ($_SERVER['HTTP_HOST'] == "clicclac.info") {
|
||||
$table['images'] = "zenphoto_images";
|
||||
$table['albums'] = "zenphoto_albums";
|
||||
}
|
||||
|
||||
// Récupérer l'ID de l'album 'photos-du-mois' ($id_album)
|
||||
$i = 0;
|
||||
$conn = new mysqli($dbhost, $dbuser, $dbpassword, $zptable);
|
||||
if ($conn->connect_error) {
|
||||
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
|
||||
exit();
|
||||
}
|
||||
$conn->set_charset("utf8");
|
||||
|
||||
$excquery = "SELECT `id` FROM `" . $table['albums'] . "` WHERE `folder` = '" . $album . "'";
|
||||
|
||||
if ($result = $conn->query($excquery)) {
|
||||
$result->data_seek(0);
|
||||
$row = $result->fetch_row();
|
||||
$id_album = $row[0];
|
||||
$result->close();
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
// Récupérer toutes les fichiers de l'album 'photos-du-mois' ($fichier[])
|
||||
|
||||
$conn = new mysqli($dbhost, $dbuser, $dbpassword, $zptable);
|
||||
if ($conn->connect_error) {
|
||||
trigger_error('Database connection failed: ' . $conn->connect_error, E_USER_ERROR);
|
||||
exit();
|
||||
}
|
||||
$conn->set_charset("utf8");
|
||||
|
||||
$pictquery = "SELECT `filename` FROM `" . $table['images'] . "` WHERE `albumid` = ? ORDER BY `date` DESC";
|
||||
|
||||
$stmt = $conn->prepare($pictquery);
|
||||
//echo $pictquery;
|
||||
if($stmt === false) {
|
||||
trigger_error('Wrong SQL: ' . $pictquery . ' Error: ' . $conn->error, E_USER_ERROR);
|
||||
}
|
||||
else {
|
||||
$stmt->bind_param('i', $id_album);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($filename);
|
||||
while ($stmt->fetch()) {
|
||||
$fichier[] = $filename;
|
||||
$i++;
|
||||
//echo $filename;
|
||||
}
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
//
|
||||
?>
|
||||
|
||||
<?php
|
||||
$aide = "<span class='aide'> ? </span><b>Utilisation:</b> cliquer sur une vignette, puis....<br />";
|
||||
$aide .= " <b><i>-sur ordinateur:</i></b> naviguer avec les touches flèches droite et gauche, quitter avec ESC.<br />";
|
||||
@@ -336,15 +296,23 @@ $aide .= " <b><i>-sur tablettes et smartphones:</i></b> balayer l'écran avec un
|
||||
<!--h4><?php echo gettext("Archives"); ?> <span class='aide'><a href="#" title="<?php echo $aide; ?>" class="tooltip"><span title="<?php echo gettext("Help"); ?>">( ? )</span></a></span></h4-->
|
||||
|
||||
<?php
|
||||
$album = 'photos-du-mois'; //Photos du mois
|
||||
//$fichier = imagesFromZPAlbum($album, $connexion);
|
||||
//preprint($images_du_mois);
|
||||
|
||||
$debut = (($ppage - 1) * $nb) +1; // page 1: 2, page 2: 14, page 3: 26
|
||||
$fin = ($debut + $nb) - 1;
|
||||
/**/
|
||||
for ($j=$debut; $j<=$fin; $j++) {
|
||||
|
||||
/*
|
||||
if ($j <= count($fichier)-1) echo displayRetina($fichier[$j],$album);
|
||||
if ($j+1 <= count($fichier)-1) echo displayRetina($fichier[$j+1],$album);
|
||||
if ($j+2 <= count($fichier)-1) echo displayRetina($fichier[$j+2],$album);
|
||||
|
||||
*/
|
||||
if ($j <= count($images_du_mois)-1) echo displayRetina($images_du_mois[$j],$album);
|
||||
if ($j+1 <= count($images_du_mois)-1) echo displayRetina($images_du_mois[$j+1],$album);
|
||||
if ($j+2 <= count($images_du_mois)-1) echo displayRetina($images_du_mois[$j+2],$album);
|
||||
|
||||
$j = $j + 2;
|
||||
}
|
||||
|
||||
@@ -359,7 +327,7 @@ for ($j=$debut; $j<=$fin; $j++) {
|
||||
<?php
|
||||
/**/
|
||||
// calcul du nombre de pages (arrondi a l'entier superieur)
|
||||
$nbpages = ceil(count($fichier) / 12);
|
||||
//$nbpages = ceil(count($fichier) / 12);
|
||||
$prec = $ppage - 1;
|
||||
$suiv = $ppage + 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user