Change folder
This commit is contained in:
176
functions.php
176
functions.php
@@ -454,21 +454,19 @@ function zenphoto_handler($atts, $content=null) {
|
||||
$selector = dess_setting('dess_lightbox_select');
|
||||
$zenphoto_url = dess_setting('dess_zenphoto');
|
||||
$size = dess_setting('dess_zp_size');
|
||||
/*
|
||||
$host = (($_SERVER['HTTPS'] != "") ? "https" : "http") . '://' . $_SERVER['HTTP_HOST'] . '/zenphoto/';
|
||||
|
||||
if (substr_count($zenphoto_url2, "https") == 1) {
|
||||
$zenphoto_url = (($_SERVER['HTTPS'] != "") ? substr_replace($zenphoto_url2, 'https', 0, 4) : $zenphoto_url2);
|
||||
}
|
||||
$zenphoto_url = $host;
|
||||
*/
|
||||
$album = ! empty( $atts['album'] ) ? $atts['album'] : '';
|
||||
$album = filter_var($album, FILTER_SANITIZE_STRING);
|
||||
|
||||
$image = ! empty( $atts['image'] ) ? $atts['image'] : '';
|
||||
$image = filter_var($image, FILTER_SANITIZE_STRING);
|
||||
|
||||
$caption = ! empty( $atts['caption'] ) ? $atts['caption'] : '';
|
||||
$caption = filter_var($caption, FILTER_SANITIZE_STRING);
|
||||
|
||||
$size = 610;
|
||||
$rnd = rand (1000, 9999);
|
||||
|
||||
//$size = 610;
|
||||
|
||||
$folder = false;
|
||||
$zenphoto_img = "";
|
||||
@@ -512,53 +510,46 @@ function zenphoto_handler($atts, $content=null) {
|
||||
$image = $img_album;
|
||||
$folder = true;
|
||||
}
|
||||
/*
|
||||
if (isset($atts['folder'])) {
|
||||
if ($atts['folder'] == "true") $folder = true;
|
||||
}
|
||||
*/
|
||||
|
||||
$img = substr($image, 0, strlen($image) - 4);
|
||||
|
||||
$filename = $zenphoto_url . 'cache/' . $album . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
|
||||
|
||||
$filename = $_SERVER["DOCUMENT_ROOT"] . '/zenphoto/' . 'cache/' . $album . '/' . urlencode($img) . '_' . $size . '_watermark.jpg';
|
||||
$zp_size = getimagesize(htmlentities($filename));
|
||||
|
||||
//if ($folder == false) $zenphoto_link = '<a rel="lightbox" href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '">';
|
||||
//if ($folder == false) $zenphoto_link = '<a href="' . $zenphoto_url . 'albums/' . $atts['album'] . '/' . $atts['image'] . '" class="entry-content">';
|
||||
$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 . '">';
|
||||
else $zenphoto_link = '<a href="' . $zenphoto_url . $album . '">';
|
||||
|
||||
$zenphoto_img .= $zenphoto_link;
|
||||
/*
|
||||
$zenphoto_img .= '<picture data-picture data-alt="">
|
||||
<!--[if IE 9]><video style="display: none;"><![endif]-->
|
||||
<source class="image_standard" srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_' . $size . '_watermark.jpg, ' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_' . ($size * 2) . '_watermark.jpg 2x">
|
||||
<source class="image_standard" srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_' . $size . '_watermark.jpg, ' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_FULL' . '_watermark.jpg 2x">
|
||||
<source class="image_medium" srcset="" media="(max-width: 767px)">
|
||||
<source class="image_small" srcset="" media="(max-width: 767px)">
|
||||
<!--[if IE 9]></video><![endif]-->
|
||||
<img class="aligncenter" srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . '_' . $size . '_watermark.jpg" ' . $zp_size[3] . 'alt="' . $img . '" />
|
||||
</picture>';
|
||||
$zenphoto_img .= '</a>';
|
||||
|
||||
/*
|
||||
$a = $atts['image'];
|
||||
$b = zp_query_exif($a); // ligne 808
|
||||
|
||||
if ($b['image_meta']['description'] != "") {
|
||||
$caption = "";
|
||||
$caption .= '<p class="wp-caption-text aligncenter" style="width:' . $zp_size[0] . 'px">';
|
||||
$caption .= $b['image_meta']['description'] . '</p>';
|
||||
|
||||
$zenphoto_img .= $caption;
|
||||
}
|
||||
*/
|
||||
$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 .= '</a>';
|
||||
|
||||
$zenphoto_img .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
|
||||
|
||||
return $zenphoto_img;
|
||||
}
|
||||
add_shortcode( 'zenphoto', 'zenphoto_handler' );
|
||||
|
||||
|
||||
/*
|
||||
zp_query: récupère les exifs depuis la bdd zenphoto
|
||||
*/
|
||||
|
||||
function zp_query_exif($zpimage) {
|
||||
|
||||
$exif = array();
|
||||
require('../Connections/cnx.php');
|
||||
|
||||
@@ -572,13 +563,11 @@ function zp_query_exif($zpimage) {
|
||||
$excquery .= "`EXIFGPSLatitude`, `EXIFGPSLatitudeRef`, `EXIFGPSLongitude`, `EXIFGPSLongitudeRef`, `EXIFGPSAltitude`, `EXIFGPSAltitudeRef`, ";
|
||||
$excquery .= "`desc`, `title`, `EXIFLensType`, `EXIFLensInfo`, `EXIFOrientation`, `credit`, `copyright`, `id` ";
|
||||
$excquery .= "FROM `" . $zp_prefix . "images` WHERE `filename` = \"$zpimage\"";
|
||||
//echo $excquery;
|
||||
|
||||
if ($result = $mysqli->query($excquery)) {
|
||||
$exif = $result->fetch_row();
|
||||
$result->close();
|
||||
}
|
||||
|
||||
//preprint($exif);
|
||||
|
||||
/*
|
||||
Array
|
||||
@@ -712,11 +701,10 @@ function add_class_lightbox($content) {
|
||||
|
||||
$selector = dess_setting('dess_lightbox_select');
|
||||
|
||||
//$selector = "gallery";
|
||||
//Check the page for link images direct to image (no trailing attributes)
|
||||
$string = '/<a href="(.*?).(jpg|jpeg|png|gif|bmp|ico)"><img(.*?)class="(.*?)wp-image-(.*?)" \/><\/a>/i';
|
||||
preg_match_all( $string, $content, $matches, PREG_SET_ORDER);
|
||||
//preprint($matches);
|
||||
|
||||
//Check which attachment is referenced
|
||||
foreach ($matches as $val) {
|
||||
$slimbox_caption = '';
|
||||
@@ -726,17 +714,14 @@ function add_class_lightbox($content) {
|
||||
|
||||
//Replace the instance with the lightbox and title(caption) references. Won't fail if caption is empty.
|
||||
$string = '<a href="' . $val[1] . '.' . $val[2] . '"><img' . $val[3] . 'class="' . $val[4] . 'wp-image-' . $val[5] . '" /></a>';
|
||||
//echo "string" . "<br>" . $string;
|
||||
//$replace = '<a href="' . $val[1] . '.' . $val[2] . '" class="gallery" title="' . $slimbox_caption . '"><img' . $val[3] . 'class="' . $val[4] . 'wp-image-' . $val[5] . '" /></a>';
|
||||
$replace = '<a href="' . $val[1] . '.' . $val[2] . '" class="' . $selector . '" ' . (($slimbox_caption != "") ? 'title="' . $slimbox_caption . '"' : '') .'><img' . $val[3] . 'class="' . $val[4] . 'wp-image-' . $val[5] . '" /></a>';
|
||||
//echo "replace" . "<br>" . $replace;
|
||||
$content = str_replace( $string, $replace, $content);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
//add_filter('the_content', 'add_class_lightbox', 2);
|
||||
add_filter('the_content', 'add_class_lightbox', 2);
|
||||
|
||||
|
||||
if ( ! function_exists( 'creator_post_nav' ) ) :
|
||||
@@ -848,12 +833,19 @@ function addexif ($content) {
|
||||
$display_exif = dess_setting('dess_display_exif');
|
||||
$display_gps = dess_setting('dess_display_gps');
|
||||
|
||||
/*
|
||||
# Avec ini_set (suffixage automatique avec un timestamp) :
|
||||
ini_set('xdebug.trace_output_dir', dirname(__FILE__));
|
||||
ini_set('xdebug.trace_output_name', 'xdebug_trace_%u');
|
||||
xdebug_start_trace(null, XDEBUG_TRACE_COMPUTERIZED);
|
||||
|
||||
# Fichier unique :
|
||||
xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
|
||||
*/
|
||||
|
||||
if ($display_exif == true) {
|
||||
|
||||
$matches3 = array();
|
||||
//$coord = array();
|
||||
|
||||
|
||||
|
||||
// Le caption
|
||||
//$pattern = '/<p .*?class="wp-caption-text">(.*?)<\/p>/';
|
||||
@@ -866,15 +858,15 @@ function addexif ($content) {
|
||||
//$pattern = '/<div id=\"?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
|
||||
// `1049`
|
||||
|
||||
$pattern = '/<div id=\"attachment_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
|
||||
//$pattern = '/<div id=[^>]*>(.*?)\<\/div>/';
|
||||
$pattern = '/<div id=\"(zp|attachment)_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
|
||||
//$pattern = '/<div id=\"attachment_?([^\"]*)\"?[^>]*>(.*?)\<\/div>/';
|
||||
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
|
||||
var_dump($matches);
|
||||
/*
|
||||
echo "matches[0][0]"; //<div id="attachment_1049">...</div>
|
||||
echo $matches[0][0];
|
||||
echo "matches[0][1]"; // 1114
|
||||
echo $matches[0][1];
|
||||
echo "matches[0][2]"; // <a href>...</a>
|
||||
echo $matches[0][2];
|
||||
*/
|
||||
|
||||
// Pour tous les DIV (attachment) on cherche les <A HREF>
|
||||
@@ -893,12 +885,18 @@ function addexif ($content) {
|
||||
echo "matches2[0][2]"; // <img src="http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-1180x787.jpg" alt="Vautour dans le brouillard de Rémuzat" width="1180" height="787" class="size-large wp-image-1114" srcset="http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-1180x787.jpg 1180w, http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-200x133.jpg 200w, http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-800x534.jpg 800w, http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-1180x787@2x.jpg 2360w, http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-200x133@2x.jpg 400w, http://macbook-pro.local/wordpress/wp-content/uploads/2017/01/2016-12-01_VautourFauve_8789-800x534@2x.jpg 1600w" sizes="(max-width: 1180px) 100vw, 1180px">
|
||||
echo $matches2[0][2];
|
||||
*/
|
||||
//echo "count(matches2): " . count($matches2) . "<br>";
|
||||
|
||||
$court = $matches2[0][1];
|
||||
|
||||
$meta = creator_get_exif( $court );
|
||||
//preprint($meta);
|
||||
|
||||
if (substr_count($court, "wordpress") > 0) $meta = creator_get_exif( $court );
|
||||
elseif (substr_count($court, "zenphoto") > 0) {
|
||||
echo $court;
|
||||
$img = explode("/", $court);
|
||||
$zp_image = end($img);
|
||||
$zp_album = prev($img);
|
||||
$meta = zp_query_exif( $zp_image );
|
||||
}
|
||||
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
$content = str_replace($matches[$i][0], $matches[$i][0] . $exifs, $content);
|
||||
@@ -916,29 +914,25 @@ function addexif ($content) {
|
||||
|
||||
$pattern2 = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
|
||||
preg_match_all($pattern2, $content , $matches4, PREG_SET_ORDER);
|
||||
|
||||
var_dump($matches4);
|
||||
|
||||
for ($i = 0; $i <= (count($matches4) - 1); $i++) {
|
||||
$ancien = $matches4[$i][0];
|
||||
$court = $matches4[$i][1];
|
||||
|
||||
// si source wordpress
|
||||
if (substr_count($ancien, "wordpress") > 0) {
|
||||
//echo "ancien: " . htmlentities($ancien) . "<br>";
|
||||
/*
|
||||
$patternWP = '#wp-image-[0-9]{1,4}#';
|
||||
if (preg_match($patternWP, $ancien, $matches5) === 1) {
|
||||
$attachment = substr($matches5[0],9);
|
||||
*/
|
||||
*/
|
||||
|
||||
// si $court est déjà dans $matches3 (si l'image est déjà dans un DIV)
|
||||
if (in_multiarray($court, $matches3) == false) {
|
||||
//echo "<b>ancien: </b>" . htmlentities($ancien) . "<br>";
|
||||
//echo "<b>court: </b>" . htmlentities($court) . "<br>";
|
||||
|
||||
$meta = creator_get_exif( $court );
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
|
||||
$content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content);
|
||||
|
||||
if (($meta['longitude'] != "") && ($meta['latitude'] != "")) {
|
||||
@@ -953,35 +947,40 @@ function addexif ($content) {
|
||||
|
||||
// si source zenphoto
|
||||
elseif ((substr_count($ancien, 'zenphoto') != 0) and (substr_count($ancien, '<img') != 0)){
|
||||
echo "<b>zenphoto</b>" . "<br>";
|
||||
|
||||
$patternZP = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
|
||||
preg_match($patternZP, $ancien , $matches2);
|
||||
|
||||
$img = explode("/", $matches2[1]);
|
||||
$zp_image = end($img);
|
||||
$zp_album = prev($img);
|
||||
// bug: si 2x la même image, les exifs sont affichés 2x
|
||||
|
||||
// si $court est déjà dans $matches3 (si l'image est déjà dans un DIV)
|
||||
if (in_multiarray($court, $matches3) == false) {
|
||||
|
||||
$patternZP = '/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU';
|
||||
preg_match($patternZP, $ancien , $matches2);
|
||||
|
||||
$img = explode("/", $matches2[1]);
|
||||
$zp_image = end($img);
|
||||
$zp_album = prev($img);
|
||||
|
||||
$meta = zp_query_exif( $zp_image );
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
|
||||
$content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content);
|
||||
|
||||
if (($meta['longitude'] != "") && ($meta['latitude'] != "")) {
|
||||
if ($meta['caption'] != "") $fichier = $meta['caption'];
|
||||
else if ($meta['title'] != "") $fichier = $meta['title'];
|
||||
else $fichier = end(explode("/", $court));
|
||||
array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier));
|
||||
}
|
||||
$meta = zp_query_exif( $zp_image );
|
||||
$exif_array = img_wp_exif( $meta );
|
||||
$exifs = "<div class='image-exif rouge'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||
|
||||
$content = str_replace($matches4[$i][0], $matches4[$i][0] . $exifs, $content);
|
||||
$exifs = "";
|
||||
if (($meta['longitude'] != "") && ($meta['latitude'] != "")) {
|
||||
if ($meta['caption'] != "") $fichier = $meta['caption'];
|
||||
else if ($meta['title'] != "") $fichier = $meta['title'];
|
||||
else $fichier = end(explode("/", $court));
|
||||
array_push($coord, array($meta['latitude'], $meta['longitude'], $fichier));
|
||||
}
|
||||
} // if in_multiarray
|
||||
|
||||
} // else zenphoto
|
||||
|
||||
// Autres sources que WP et ZP
|
||||
elseif (substr_count($ancien, 'jpg') > 0) {
|
||||
|
||||
echo $ancien;
|
||||
echo "court2: " . $court . "<br>";
|
||||
$meta = creator_get_exif( $court );
|
||||
//$flk_size = getimagesize(htmlentities($filename3));
|
||||
/*
|
||||
Flicker (portrait):
|
||||
<a href="https://flic.kr/p/Cn2dTd"><img src="https://farm2.staticflickr.com/1704/23866728514_76a72305a9_c.jpg" portrait /></a>
|
||||
@@ -1008,14 +1007,9 @@ function addexif ($content) {
|
||||
//$anc = str_replace("/></a>", "class='aligncenter' /></a>", $ancien) . "\r\n";
|
||||
|
||||
} // else
|
||||
|
||||
$exif = "";
|
||||
|
||||
} // for
|
||||
|
||||
//preprint ($coord);
|
||||
|
||||
|
||||
|
||||
|
||||
return $content;
|
||||
|
||||
@@ -1114,6 +1108,7 @@ function creator_get_exif( $file ) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
//echo "file: " . $file . "<br>";
|
||||
|
||||
list( , , $sourceImageType ) = getimagesize( $file );
|
||||
|
||||
@@ -1629,6 +1624,17 @@ function childtheme_customize_register( $wp_customize ) {
|
||||
'section' => 'settings_section',
|
||||
'type' => 'text',
|
||||
)));
|
||||
$wp_customize->add_setting('dess_zp_size', array(
|
||||
'capability' => 'edit_theme_options',
|
||||
'type' => 'theme_mod',
|
||||
'sanitize_callback' => 'dess_sanitize_html',
|
||||
));
|
||||
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dess_zp_size', array(
|
||||
'settings' => 'dess_zp_size',
|
||||
'label' => __('Zenphoto image size (px)','CreatorThemeRes-child'),
|
||||
'section' => 'settings_section',
|
||||
'type' => 'text',
|
||||
)));
|
||||
$wp_customize->add_setting('dess_social_size', array(
|
||||
'capability' => 'edit_theme_options',
|
||||
'type' => 'theme_mod',
|
||||
|
||||
14
single.php
14
single.php
@@ -20,7 +20,12 @@ get_header();
|
||||
|
||||
<?php
|
||||
$coord = array();
|
||||
|
||||
xdebug_start_trace(null,XDEBUG_TRACE_HTML);
|
||||
|
||||
the_content();
|
||||
|
||||
xdebug_stop_trace();
|
||||
?>
|
||||
|
||||
<?php //$content = apply_filters('the_content', get_the_content());
|
||||
@@ -65,6 +70,7 @@ get_header();
|
||||
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
|
||||
var markers = new Array();
|
||||
var iconCounter = 0;
|
||||
for (i = 0; i < locations.length; i++) {
|
||||
marker = new google.maps.Marker({
|
||||
@@ -72,6 +78,8 @@ get_header();
|
||||
map: map,
|
||||
icon: icons[iconCounter]
|
||||
});
|
||||
|
||||
/*markers.push(marker);*/
|
||||
|
||||
bounds.extend(marker.position);
|
||||
|
||||
@@ -91,6 +99,12 @@ get_header();
|
||||
infowindow.open(map, marker);
|
||||
}
|
||||
})(marker, i));
|
||||
|
||||
iconCounter++;
|
||||
if (iconCounter >= iconsLength) {
|
||||
iconCounter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
map.fitBounds(bounds);
|
||||
|
||||
@@ -154,6 +154,7 @@ input.search-field {
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.exif-data {
|
||||
@@ -176,6 +177,9 @@ input.search-field {
|
||||
|
||||
/* Single */
|
||||
|
||||
.zenphoto {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.wp-caption {
|
||||
margin-top: 24px !important;
|
||||
margin-bottom: 8px !important;
|
||||
|
||||
Reference in New Issue
Block a user