diff --git a/functions.php b/functions.php index 9caec44..e985292 100644 --- a/functions.php +++ b/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 = ''; - //if ($folder == false) $zenphoto_link = ''; + $zenphoto_img = (($caption != "") ? '
' : ''); + if ($folder == false) $zenphoto_link = ''; else $zenphoto_link = ''; $zenphoto_img .= $zenphoto_link; + /* $zenphoto_img .= ' - + '; - $zenphoto_img .= ''; - - /* - $a = $atts['image']; - $b = zp_query_exif($a); // ligne 808 - - if ($b['image_meta']['description'] != "") { - $caption = ""; - $caption .= '

'; - $caption .= $b['image_meta']['description'] . '

'; - - $zenphoto_img .= $caption; - } */ + $zenphoto_img .= '…'; + $zenphoto_img .= ''; + + $zenphoto_img .= (($caption != "") ? '

' . $caption . '

' : ''); 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>/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 = ''; - //echo "string" . "
" . $string; - //$replace = ''; $replace = ''; - //echo "replace" . "
" . $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>/'; @@ -866,15 +858,15 @@ function addexif ($content) { //$pattern = '/

]*>(.*?)\<\/div>/'; // `1049` - $pattern = '/
]*>(.*?)\<\/div>/'; + //$pattern = '/
]*>(.*?)\<\/div>/'; + $pattern = '/
]*>(.*?)\<\/div>/'; + //$pattern = '/
]*>(.*?)\<\/div>/'; preg_match_all($pattern, $content, $matches, PREG_SET_ORDER); + var_dump($matches); /* echo "matches[0][0]"; //
...
- echo $matches[0][0]; echo "matches[0][1]"; // 1114 - echo $matches[0][1]; echo "matches[0][2]"; // ... - echo $matches[0][2]; */ // Pour tous les DIV (attachment) on cherche les @@ -893,12 +885,18 @@ function addexif ($content) { echo "matches2[0][2]"; // Vautour dans le brouillard de Rémuzat echo $matches2[0][2]; */ - //echo "count(matches2): " . count($matches2) . "
"; $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 = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; $content = str_replace($matches[$i][0], $matches[$i][0] . $exifs, $content); @@ -916,29 +914,25 @@ function addexif ($content) { $pattern2 = '/]*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) . "
"; /* $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 "ancien: " . htmlentities($ancien) . "
"; - //echo "court: " . htmlentities($court) . "
"; - $meta = creator_get_exif( $court ); $exif_array = img_wp_exif( $meta ); $exifs = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; - $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, 'zenphoto" . "
"; - - $patternZP = '/]*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 = '/]*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 = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; - - $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 = "
" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "
"; + + $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 . "
"; $meta = creator_get_exif( $court ); +//$flk_size = getimagesize(htmlentities($filename3)); /* Flicker (portrait):
@@ -1008,14 +1007,9 @@ function addexif ($content) { //$anc = str_replace("/>", "class='aligncenter' />", $ancien) . "\r\n"; } // else - + $exif = ""; } // for - - //preprint ($coord); - - - return $content; @@ -1114,6 +1108,7 @@ function creator_get_exif( $file ) { return false; } */ + //echo "file: " . $file . "
"; 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', diff --git a/single.php b/single.php index 7501d93..1a2be96 100755 --- a/single.php +++ b/single.php @@ -20,7 +20,12 @@ get_header(); = iconsLength) { + iconCounter = 0; + } + } map.fitBounds(bounds); diff --git a/style.css b/style.css index 65dff92..fe70c80 100644 --- a/style.css +++ b/style.css @@ -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;