Single (WP et ZP terminé)

-alt
-title (pour lightbox)
This commit is contained in:
2017-02-12 18:52:59 +01:00
parent c7cb1d7a02
commit a722102766
2 changed files with 58 additions and 32 deletions

View File

@@ -464,53 +464,76 @@ function zenphoto_handler($atts, $content=null) {
$caption = ! empty( $atts['caption'] ) ? $atts['caption'] : '';
$caption = filter_var($caption, FILTER_SANITIZE_STRING);
//echo "album: " . $album . " image: " . $image . "<br>";
$rnd = rand (1000, 9999);
//$size = 610;
$folder = false;
//echo "folder1: " . $folder . "<br>";
$zenphoto_img = "";
// Si ALBUM mais pas IMAGE
//if ((isset($atts['album'])) && (!isset($atts['image']))) {
if (($album != "") && ($image == "")) {
require('../Connections/cnx.php');
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
// Trouver l'ID de l'album
$album_id_query = "SELECT `id` FROM `" . $zp_prefix . "albums` WHERE `folder` = '" . $atts['album'] . "'";
if ($result = $mysqli->query($album_id_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$album_id = $row[0];
}
else {
_e("Unknow album.", 'CreatorThemeRes-child' );
}
$result->close();
}
//echo "album2: " . $album . " image2: " . $image . "<br>";
// Trouver le filename de la plus récente image de l'album
$img_album_query = "SELECT filename FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "' ORDER BY `id` DESC LIMIT 1";
//if (($album != "") && ($image == "")) {
require('../Connections/cnx.php');
$mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbtable);
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
exit();
}
// Trouver l'ID de l'album
$album_id_query = "SELECT `id` FROM `" . $zp_prefix . "albums` WHERE `folder` = '" . $atts['album'] . "'";
if ($result = $mysqli->query($album_id_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$album_id = $row[0];
}
else {
_e("Unknow album.", 'CreatorThemeRes-child' );
}
$result->close();
}
$img_query = "SELECT `desc`, `title`, `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "'";
if ($result = $mysqli->query($img_query)) {
if ($mysqli->affected_rows != 0) {
$capt = $result->fetch_row();
}
else {
_e("Unknow image.", 'CreatorThemeRes-child' );
}
$result->close();
}
if (($album != "") && ($image == "")) {
// Trouver le filename de la plus récente image de l'album
$img_album_query = "SELECT `filename` FROM `" . $zp_prefix . "images` WHERE `albumid` = '" . $album_id . "' ORDER BY `id` DESC LIMIT 1";
if ($result = $mysqli->query($img_album_query)) {
if ($mysqli->affected_rows != 0) {
$row = $result->fetch_row();
$img_album = $row[0];
$img_album = $row[0];
}
else {
_e("Unknow image.", 'CreatorThemeRes-child' );
_e("Unknow image.", 'CreatorThemeRes-child' );
}
$result->close();
$result->close();
}
$image = $img_album;
$folder = true;
}
} // album != ""
if ($capt[0] != "") $title = $capt[0];
elseif ($capt[1] != "") $title = $capt[1];
elseif ($capt[2] != "") $title = $capt[2];
$img = substr($image, 0, strlen($image) - 4);
$filename = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . 'cache/' . $album . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
@@ -518,7 +541,7 @@ function zenphoto_handler($atts, $content=null) {
$zenphoto_img = (($caption != "") ? '<div id="zp_' . $rnd . '" style="width: ' . ($zp_size[0] + 10) . 'px" class="wp-caption aligncenter">' : '');
if ($folder == false) $zenphoto_link = '<a href="' . $zenphoto_url . 'albums/' . $album . '/' . $image . '" class="' . $selector . '">';
if ($folder == false) $zenphoto_link = '<a href="' . $zenphoto_url . 'albums/' . $album . '/' . $image . '" class="' . $selector . '" title="' . $title . '">';
else $zenphoto_link = '<a href="' . $zenphoto_url . $album . '">';
$zenphoto_img .= $zenphoto_link;
@@ -534,7 +557,7 @@ function zenphoto_handler($atts, $content=null) {
*/
$zenphoto_img .= '<img class="';
$zenphoto_img .= (($caption == "") ? 'aligncenter size-medium"' : '"');
$zenphoto_img .= 'srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="" />';
$zenphoto_img .= 'srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="' . $img . '" />';
$zenphoto_img .= '</a>';
$zenphoto_img .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
@@ -862,7 +885,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
$pattern = '/<div id=\"(zp|attachment)_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
//$pattern = '/<div id=\"attachment_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
var_dump($matches);
//var_dump($matches);
/*
echo "matches[0][0]"; //<div id="attachment_1049">...</div>
echo "matches[0][1]"; // 1114
@@ -890,7 +913,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
if (substr_count($court, "wordpress") > 0) $meta = creator_get_exif( $court );
elseif (substr_count($court, "zenphoto") > 0) {
echo $court;
//echo $court;
$img = explode("/", $court);
$zp_image = end($img);
$zp_album = prev($img);
@@ -914,7 +937,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
$pattern2 = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
preg_match_all($pattern2, $content , $matches4, PREG_SET_ORDER);
var_dump($matches4);
//var_dump($matches4);
for ($i = 0; $i <= (count($matches4) - 1); $i++) {
$ancien = $matches4[$i][0];