Version 3.0

This commit is contained in:
Deltacms 2023-10-20 11:24:09 +02:00
parent 58e1f713e1
commit 4b01417591
8 changed files with 130 additions and 193 deletions

View File

@ -5,7 +5,7 @@
*/
setlocale(LC_NUMERIC,'English','en_US','en_US.UTF-8');
class album extends common {
const VERSION = '2.6';
const VERSION = '3.0';
const REALNAME = 'Album Photo';
const DELETE = true;
const UPDATE = '0.0';

View File

@ -1,6 +1,6 @@
<?php
/* création des miniatures par @Lionel 2019
* modification le 08 octobre 2023
/* création des miniatures @Lionel Croquefer 2019
* modification le 19 octobre 2023
*/
if (!isset($_GET['img']))
{
@ -11,10 +11,13 @@ if ( is_file($img) && substr(mime_content_type($img), 0, 5) == 'image' ) {
function makeDir($dir) {
if ( (!is_dir($dir)) || (!file_exists($dir)) )
mkdir($dir,0755,true);
@mkdir($dir,0755,true);
}
$ratio = 200;
// taille des miniatures
$tnlarge = 320;/*267*/
$tnhaut = ($tnlarge/1.6);/*200*/
$size_img = filesize($img);
$dossiercache = '../../../site/file/cache';
makeDir($dossiercache);
@ -24,42 +27,50 @@ $cache = substr(strrchr($url_par, '/'), 1);
makeDir($dossiercache.'/'.$cache);
$extension = strrchr($par,'.');
$vignette = str_replace($extension,'',$par);
$miniature = $dossiercache.'/'.$cache.'/'.$vignette.'-'.$size_img.'.webp';
$miniature = $dossiercache.'/'.$cache.'/tn-'.$vignette.'-'.$size_img.'.webp';
if(!file_exists($miniature)) {
$imginfo = getimagesize($img);
$largeur = $imginfo[0];
$hauteur = $imginfo[1];
$type = $imginfo[2];
if($type == 1)
{
$src = imagecreatefromgif($img);
}
elseif($type == 2)
{
$src = imagecreatefromjpeg($img);
}
elseif($type == 3)
{
$src = imagecreatefrompng($img);
}
elseif($type == 18)
{
$src = imagecreatefromwebp($img);
}
imageinterlace($src, true);
if ($largeur > $hauteur)
{
$im = imagecreatetruecolor(round(($ratio/$hauteur)*$largeur), $ratio);
imagecopyresampled($im, $src, 0, 0, 0, 0, round(($ratio/$hauteur)*$largeur), $ratio, $largeur, $hauteur);
}
else
{
$im = imagecreatetruecolor($ratio, round(($ratio/$largeur)*$hauteur));
imagecopyresampled($im, $src, 0, 0, 0, 0, $ratio, round($hauteur*($ratio/$largeur)), $largeur, $hauteur);
}
imagewebp($im, $miniature, 80);
imagedestroy($im);
if (!file_exists($miniature)) {
list($width, $height, $type, $attr) = getimagesize($img);
if ($height > $tnhaut)
{
$convert = $tnhaut/$height;
$height = $tnhaut;
$width = ceil($width*$convert);
}
if ($width > $tnlarge)
{
$convert = $tnlarge/$width;
$width = $tnlarge;
$height = ceil($height*$convert);
}
$largeur = $width;
$hauteur = $height;
if($type == 1)
{
$img_in = imagecreatefromgif($img);
}
elseif($type == 2)
{
$img_in = imagecreatefromjpeg($img);
}
elseif($type == 3)
{
$img_in = imagecreatefrompng($img);
}
elseif($type == 18)
{
$img_in = imagecreatefromwebp($img);
}
imageinterlace($img_in, true);
$img_out = imagecreatetruecolor($largeur, $hauteur) or die ('Impossible de créer un flux d\'image GD');
imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
imagewebp($img_out, $miniature, 80);
imagedestroy($img_out);
}
header('Content-Type: image/webp');
$data = file_get_contents($miniature);

View File

@ -1,14 +1,20 @@
.gallery {
section > * {
box-sizing: border-box;
padding: 0;
}
section > .row:not(.back) > .col2 {
padding: 5px;
}
.gallery {
position: relative;
}
.galleryGalleryPicture {
box-sizing: content-box;
padding: 12px 0 2px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
height: 185px;/*fluide*/
max-height: 36vmin;
text-align: center;
background-color: rgba(230, 230, 230, 0.7);
border: 1px solid #ddd;
@ -19,59 +25,48 @@
background-color: rgb(192, 192, 192);
}
.galleryGalleryName {
position: absolute;
left: 0;
right: 0;
bottom: 0;
line-height: 1.2;
color: #000;
overflow: hidden;
font-size: 0.85em;
}
.galleryGalleryPicture img {
max-height: 80%;
.galleryGalleryPicture > figure > img {
max-height: 20vmin;
max-width: 95%;
object-fit: contain;
}
.picResized {
color: crimson;
}
.osm {
position: absolute;
left:10px;
bottom:10px;
right:10px;
top:10px;
}
/* adaptation */
@media (max-width: 1281px) {
.galleryGalleryPicture {
height: 160px;
}
figure, figcaption {
border: none;
margin: 0;
padding: 0;
}
/* styles adaptatifs */
@media (max-width: 1025px) {
.galleryGalleryPicture {
height: 135px;
}
.galleryGalleryName {
font-size: 0.75em;
font-size: 0.78em;
}
}
@media (max-width: 813px) {
.galleryGalleryPicture {
height: 120px;
}
}
@media (max-width: 799px) {
section > .row:not(.back) {
display: flex;
flex-wrap: wrap;
padding: 0 10px;
justify-content: space-evenly;
}
.gallery {
flex: 0 0 33.3333%;
}
.col2:not(.gallery) {
width: inherit;
.galleryGalleryPicture > figure > img {
max-height: 25vmin;
}
}
@media (max-width: 599px) {
.gallery {
flex: 0 0 50%;
@ -79,4 +74,7 @@ section > .row:not(.back) {
.galleryGalleryName {
display: none;
}
}
.galleryGalleryPicture {
padding: 12px 0 7px;
}
}

View File

@ -9,30 +9,3 @@
captionsData: "caption",
closeText: "&times;"
});
$(function () {
var taille = "<?php echo $this->getData(['theme','site', 'width']); ?>";
switch(taille)
{
case '75vw':
$('a.galleryGalleryPicture').css('height', '125px');
$('div.galleryGalleryName').css('font-size', '0.8em');
$('div.galleryGalleryName').css('line-height', '1em');
break;
case '85vw':
$('a.galleryGalleryPicture').css('height', '135px');
$('div.galleryGalleryName').css('font-size', '0.85em');
$('div.galleryGalleryName').css('line-height', '1em');
break;
case '95vw':
$('a.galleryGalleryPicture').css('height', '160px');
$('div.galleryGalleryName').css('font-size', '0.9em');
break;
default:
$('a.galleryGalleryPicture').css('height', '185px');
$('div.galleryGalleryName').css('font-size', '1em');
break;
}
});

View File

@ -2,18 +2,7 @@
// Lexique
$param = '';
include('./module/album/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_album.php');
?>
<div class="row back">
<div class="col2">
<?php echo template::button('galleryGalleryBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . $this->getUrl(0),
'ico' => 'left',
'value' => $text['album_view']['gallery'][0]
]); ?>
</div>
</div>
<?php
$i = 1;
$picturesNb = count($module::$pictures);
foreach($module::$pictures as $picture => $legend):
@ -36,14 +25,14 @@ $get_location = albumHelper::gps_exif($picture);
<?php endif; ?>
<div class="col2 gallery">
<a href="<?php echo $picture; ?>" class="galleryGalleryPicture" data-caption="<?php echo $legend; ?>">
<img src="module/album/plugins/thumbnailer.php?img=<?php echo $picture; ?>" alt="<?php echo $legend; ?>">
<?php if ($photo_960 !== false): ?>
<div class="galleryGalleryName picResized" onclick="window.open('<?=$urlback?>');" data-tippy-content="image originale">
<figure class="album"><img src="module/album/plugins/thumbnailer.php?img=<?php echo $picture; ?>" alt="<?php echo $legend; ?>">
<?php if ( ($photo_960 !== false) && (file_exists($urloriginal)) ): ?>
<figcaption><div class="galleryGalleryName picResized" onclick="window.open('<?=$urlback?>');" data-tippy-content="image originale">
<?php else: ?>
<div class="galleryGalleryName">
<figcaption><div class="galleryGalleryName">
<?php endif;
if (!empty($legend)):
$shortenedLegend = helper::subword($legend, 0, 25);
$shortenedLegend = helper::subword($legend, 0, 20);
if ( strlen($shortenedLegend) < strlen($legend) ) $legend = $shortenedLegend.'...';
echo $legend;
// nettoyage et affichage du nom des images
@ -51,10 +40,12 @@ $get_location = albumHelper::gps_exif($picture);
$separe = array('_','-','t960');
$picname = str_replace($separe, ' ', $photo);
$picname = preg_replace('/(\.jpe?g|\.png|\.gif|\.webp)$/i', '', $picname);
echo substr($picname,0,25);
$shortenedPicname = helper::subword($picname, 0, 20);
if ( strlen($shortenedPicname) < strlen($picname) ) $picname = $shortenedPicname.'...';
echo $picname;
endif;
?>
</div>
</div></figcaption></figure>
</a>
<?php
// ajout du marqueur aux images contenant des données exif gps
@ -78,3 +69,13 @@ $get_location = albumHelper::gps_exif($picture);
$i++;
endforeach;
?>
<div class="row back">
<div class="col2">
<?php echo template::button('galleryGalleryBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . $this->getUrl(0),
'ico' => 'left',
'value' => $text['album_view']['gallery'][0]
]); ?>
</div>
</div>

View File

@ -1,16 +1,20 @@
.col3 {
section > * {
box-sizing: border-box;
padding: 0;
}
section > .row > .col3 {
padding: 5px;
}
.galleryPicture {
box-sizing: content-box;
padding: 22px 0 5px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
height: 220px;
max-height: 50vmin;
text-align: center;
background-color: rgba(230, 230, 230, 0.7);
border: 1px solid #ddd;
border: 1px solid rgba(0,0,0,0.2);
border-radius: 6px;
transition: background-color 1.3s ease;
}
@ -18,37 +22,20 @@
background-color: rgb(192, 192, 192);
}
.galleryName {
position: absolute;
left: 0;
right: 0;
bottom: 0;
line-height: 1.5;
color: #000;
line-height: 1.25;
font-size: 0.85em;
}
.galleryPicture img {
max-height: 80%;
.galleryPicture > figure > img {
max-height: 25vmin;
max-width: 95%;
object-fit: contain;
}
/* adaptation */
@media (max-width: 1281px) {
.galleryPicture {
height: 210px;
}
}
@media (max-width: 1025px) {
.galleryPicture {
height: 180px;
}
.galleryName {
font-size: 0.75em;
}
}
@media (max-width: 961px) {
.galleryPicture {
height: 165px;
}
figure, figcaption {
border: none;
margin: 0;
padding: 0;
}
/* styles adaptatifs */
@media (max-width: 799px) {
section > .row {
display: flex;
@ -56,21 +43,12 @@ section > .row {
justify-content: space-evenly;
}
section > .row > .col3 {
max-width: 50%;
flex: 0 0 50%;
}
}
@media (max-width: 799px) and (orientation: portrait) {
/*
@media (max-width: 799px) and (orientation: landscape) {
.galleryPicture {
max-height: 45vmin;
}
}
@media (min-width: 768px) and (max-width: 799px) and (orientation: portrait) {
section > .row {
display: flex;
flex-wrap: wrap;
justify-content: start;
}
.col3 {
flex: 0 0 25%;
}
padding: 30px 0;
}
*/

View File

@ -1,29 +0,0 @@
/**
* This file is part of DeltaCMS.
* Album Photo /view/index
*/
$(function () {
var taille = "<?php echo $this->getData(['theme','site', 'width']); ?>";
switch(taille)
{
case '75vw':
$('a.galleryPicture').css('height', '170px');
$('div.galleryName').css('font-size', '0.8em');
break;
case '85vw':
$('a.galleryPicture').css('height', '200px');
$('div.galleryName').css('font-size', '0.85em');
break;
case '95vw':
$('a.galleryPicture').css('height', '235px');
$('div.galleryName').css('font-size', '0.9em');
break;
default:
$('a.galleryPicture').css('height', '250px');
$('div.galleryName').css('font-size', '1em');
break;
}
});

View File

@ -4,6 +4,11 @@
$param = '';
include('./module/album/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_album.php');
// supprime le fichier inutile de la version 2.5
if (file_exists('module/album/view/index/index.js.php')) {
unlink('module/album/view/index/index.js.php');
}
if($module::$galleries):
$i = 1;
$galleriesNb = count($module::$galleries);
@ -14,12 +19,12 @@ if($i % 4 === 1):
<?php endif; ?>
<div class="col3">
<a href="<?php echo helper::baseUrl() . $this->getUrl(0); ?>/<?php echo $galleryId; ?>" class="galleryPicture">
<img src="<?php if ($this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'homePicture']) === null ) {
<figure class="album"><img src="<?php if ($this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'homePicture']) === null ) {
echo 'module/album/plugins/thumbnailer.php?img=' . $module::$firstPictures[$galleryId]; }
else {
echo 'module/album/plugins/thumbnailer.php?img=' . $this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'directory']) . '/' . $this->getData(['module', $this->getUrl(0), $galleryId, 'config', 'homePicture']);
} ?>" alt="<?php echo $gallery['config']['name']; ?>">
<div class="galleryName"><?php echo $gallery['config']['name']; ?></div>
<figcaption><div class="galleryName"><?php echo $gallery['config']['name']; ?></div></figcaption></figure>
</a>
</div>
<?php if($i % 4 === 0 OR $i === $galleriesNb): ?>