Flickr
-shortcode flickr (avec exif et geodata)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
/.settings
|
/.settings
|
||||||
/.buildpath
|
/.buildpath
|
||||||
/.project
|
/.project
|
||||||
|
/-child
|
||||||
|
|||||||
233
functions.php
233
functions.php
@@ -385,8 +385,73 @@ function date_archive ($chaine) {
|
|||||||
|
|
||||||
|
|
||||||
function flickr_handler($atts, $content=null) {
|
function flickr_handler($atts, $content=null) {
|
||||||
// flickr = pas d'exifs
|
|
||||||
|
|
||||||
|
global $coord;
|
||||||
|
$api_key = "3884af4190ac97a95fd4777dba0d9f21";
|
||||||
|
|
||||||
|
extract(shortcode_atts(array(
|
||||||
|
"pid" => $atts[0],
|
||||||
|
"version"=>"Medium 800", //setting default value
|
||||||
|
"caption"=>"", //setting default value
|
||||||
|
"url"=>""
|
||||||
|
), $atts));
|
||||||
|
if($url != ""){
|
||||||
|
$e=explode("/",$url);
|
||||||
|
$pid=$e[5];
|
||||||
|
}
|
||||||
|
|
||||||
|
//echo $pid . " - ". $version . " - ". $caption . " - ". $url . "<br>";
|
||||||
|
// 27868468454 - Medium - - https://www.flickr.com/photos/funnymac/27868468454/
|
||||||
|
|
||||||
|
/*
|
||||||
|
[flickr url="https://www.flickr.com/photos/funnymac/27868468454/"]
|
||||||
|
|
||||||
|
[flickr pid="27868468454"]
|
||||||
|
|
||||||
|
[flickr pid="27868468454" version="Small"]
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch (strtolower($version)) {
|
||||||
|
case "square":
|
||||||
|
$img_sd = "Square";
|
||||||
|
$img_hd = "Large Square";
|
||||||
|
break;
|
||||||
|
case "large square":
|
||||||
|
$img_sd = "Square";
|
||||||
|
$img_hd = "Large Square";
|
||||||
|
break;
|
||||||
|
case "small":
|
||||||
|
$img_sd = "Small";
|
||||||
|
$img_hd = "Medium";
|
||||||
|
break;
|
||||||
|
case "small 320":
|
||||||
|
$img_sd = "Small 320";
|
||||||
|
$img_hd = "Medium 640";
|
||||||
|
break;
|
||||||
|
case "medium":
|
||||||
|
$img_sd = "Medium";
|
||||||
|
$img_hd = "Large";
|
||||||
|
break;
|
||||||
|
case "medium 640":
|
||||||
|
$img_sd = "Small 320";
|
||||||
|
$img_hd = "Medium 640";
|
||||||
|
break;
|
||||||
|
case "medium 800":
|
||||||
|
$img_sd = "Medium 800";
|
||||||
|
$img_hd = "Large 1600";
|
||||||
|
break;
|
||||||
|
case "large":
|
||||||
|
$img_sd = "Medium";
|
||||||
|
$img_hd = "Large";
|
||||||
|
break;
|
||||||
|
case "large 1600":
|
||||||
|
$img_sd = "Medium 800";
|
||||||
|
$img_hd = "Large 1600";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//echo $img_sd . " - ". $img_hd . "<br>";
|
||||||
|
/*
|
||||||
$link = ! empty( $atts['link'] ) ? $atts['link'] : '';
|
$link = ! empty( $atts['link'] ) ? $atts['link'] : '';
|
||||||
$link = filter_var($link, FILTER_SANITIZE_URL);
|
$link = filter_var($link, FILTER_SANITIZE_URL);
|
||||||
|
|
||||||
@@ -407,34 +472,162 @@ function flickr_handler($atts, $content=null) {
|
|||||||
$lb = ! empty( $atts['lb'] ) ? $atts['lb'] : '';
|
$lb = ! empty( $atts['lb'] ) ? $atts['lb'] : '';
|
||||||
$lb = filter_var($lb, FILTER_SANITIZE_STRING);
|
$lb = filter_var($lb, FILTER_SANITIZE_STRING);
|
||||||
$info = array();
|
$info = array();
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// 1220 -610
|
// 1220 -610
|
||||||
$lb = toBool($lb);
|
$lb = toBool($lb);
|
||||||
$rnd = rand (1000, 9999);
|
$rnd = rand (1000, 9999);
|
||||||
$selector = dess_setting('dess_lightbox_select');
|
$selector = dess_setting('dess_lightbox_select');
|
||||||
|
|
||||||
$flickr_size = getimagesize(htmlentities($small), $info);
|
|
||||||
if (isset($info["APP13"])) {
|
|
||||||
$iptc = iptcparse($info["APP13"]);
|
$url1 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getSizes';
|
||||||
//var_dump($iptc);
|
$url1 .= '&api_key='.$api_key;
|
||||||
|
$url1 .= '&photo_id='.$pid;
|
||||||
|
$url1 .= '&format=json';
|
||||||
|
$url1 .= '&nojsoncallback=1';
|
||||||
|
|
||||||
|
$result = file_get_contents($url1);
|
||||||
|
$response = json_decode($result, true);
|
||||||
|
//preprint($response);
|
||||||
|
|
||||||
|
$taille = $response['sizes']['size'];
|
||||||
|
|
||||||
|
foreach ($taille as $val) {
|
||||||
|
if ($val['label'] == $img_sd) {
|
||||||
|
$mediumSRC = $val['source'];
|
||||||
|
$w_mediumSRC = $val['width'];
|
||||||
|
$h_mediumSRC = $val['height'];
|
||||||
|
}
|
||||||
|
if ($val['label'] == $img_hd) {
|
||||||
|
$largeSRC = $val['source'];
|
||||||
|
$w_largeSRC = $val['width'];
|
||||||
|
$h_largeSRC = $val['height'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//else echo "no info !!";
|
|
||||||
|
|
||||||
$links = (($caption != "") ? '<div id="flickr_' . $rnd . '" style="width: ' . ($flickr_size[0] + 10) . 'px" class="wp-caption aligncenter">' : '');
|
/* Info de l'image */
|
||||||
|
|
||||||
$links .= '<a href="' . $link . '" class="' . (($lb == true) ? $selector : '') . '">';
|
$url2 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getInfo';
|
||||||
$links .= '<picture data-picture data-alt="">';
|
$url2 .= '&api_key='.$api_key;
|
||||||
$links .= '<!--[if IE 9]><video style="display: none;"><![endif]-->';
|
$url2 .= '&photo_id='.$pid;
|
||||||
//$link .= '<source class="image_standard" srcset="' . $atts['small'] . ', ' . $atts['big'] . ' 2x">';
|
$url2 .= '&format=json';
|
||||||
$links .= '<source class="image_standard" srcset="' . $small . (($big != "") ? ', ' . $big . ' 2x' : '') . '">';
|
$url2 .= '&nojsoncallback=1';
|
||||||
$links .= '<source class="image_medium" srcset="" media="(max-width: 767px)">';
|
|
||||||
$links .= '<source class="image_small" srcset="" media="(max-width: 767px)">';
|
$result2 = file_get_contents($url2);
|
||||||
$links .= '<!--[if IE 9]></video><![endif]-->';
|
$response2 = json_decode($result2, true);
|
||||||
$links .= '<img class="aligncenter" srcset="' . $small . '" ' . $flickr_size[3] . ' alt="' . $alt . '" />';
|
//var_dump($response2);
|
||||||
$links .= '</picture></a>';
|
|
||||||
|
$title = $response2['photo']['title']['_content'];
|
||||||
|
$date = $response2['photo']['dates']['taken'];
|
||||||
|
$lat = $response2['photo']['location']['latitude'];
|
||||||
|
$long = $response2['photo']['location']['longitude'];
|
||||||
|
$tag = $response2['photo']['tags']['tag'];
|
||||||
|
$desc = $response2['photo']['description']['_content'];
|
||||||
|
$copy = $response2['photo']['owner']['username'];
|
||||||
|
|
||||||
|
$tags = array();
|
||||||
|
foreach ($tag as $val) {
|
||||||
|
//$i = $val['_content'];
|
||||||
|
$i = $val['raw'];
|
||||||
|
$tags[] = utf8_encode(ucfirst($i));
|
||||||
|
}
|
||||||
|
|
||||||
|
$img = array(
|
||||||
|
'medium' => $mediumSRC,
|
||||||
|
'large' => $largeSRC
|
||||||
|
//'titre' => $title,
|
||||||
|
//'date' => $date,
|
||||||
|
//'latitude' => $lat,
|
||||||
|
//'longitude' => $long,
|
||||||
|
//'tags' => $tags
|
||||||
|
);
|
||||||
|
|
||||||
|
/* EXIF */
|
||||||
|
|
||||||
|
$url3 = 'https://api.flickr.com/services/rest/?method=flickr.photos.getExif';
|
||||||
|
$url3 .= '&api_key='.$api_key;
|
||||||
|
$url3 .= '&photo_id='.$pid;
|
||||||
|
$url3 .= '&format=json';
|
||||||
|
$url3 .= '&nojsoncallback=1';
|
||||||
|
|
||||||
|
$result3 = file_get_contents($url3);
|
||||||
|
$response3 = json_decode($result3, true);
|
||||||
|
|
||||||
|
$exif = $response3['photo']['exif'];
|
||||||
|
//preprint($exif);
|
||||||
|
|
||||||
|
$meta = array();
|
||||||
|
foreach ($exif as $val) {
|
||||||
|
//preprint($val);
|
||||||
|
|
||||||
|
if ($val['tag'] == 'FNumber') $meta['aperture'] = $val['raw']['_content'];
|
||||||
|
//if ($val['tag'] == 'xxx') $meta['credit'] = $val['raw']['_content'];
|
||||||
|
$meta['credit'] = $copy;
|
||||||
|
if ($val['tag'] == 'Model') $meta['camera'] = $val['raw']['_content'];
|
||||||
|
//if ($val['tag'] == 'xxx') $meta['caption'] = $val['raw']['_content'];
|
||||||
|
if ($val['tag'] == 'DateTimeOriginal') $meta['created_timestamp'] = strtotime($val['raw']['_content']);
|
||||||
|
//if ($val['tag'] == 'xxx') $meta['copyright'] = $val['raw']['_content'];
|
||||||
|
if ($val['tag'] == 'FocalLength') $meta['focal_length'] = $val['raw']['_content'];
|
||||||
|
if ($val['tag'] == 'ISO') $meta['iso'] = $val['raw']['_content'];
|
||||||
|
if ($val['tag'] == 'ExposureTime') $meta['shutter_speed'] = $val['raw']['_content'];
|
||||||
|
//if ($val['tag'] == 'xxx') $meta['title'] = $val['raw']['_content'];
|
||||||
|
$meta['title'] = $title;
|
||||||
|
if ($val['tag'] == 'Orientation') $meta['orientation'] = $val['raw']['_content'];
|
||||||
|
$meta['latitude'] = $lat;
|
||||||
|
$meta['longitude'] = $long;
|
||||||
|
$meta['keywords'] = $tags;
|
||||||
|
//$meta['latitudeRef']
|
||||||
|
//$meta['longitudeRef']
|
||||||
|
//$meta['altitude']
|
||||||
|
$meta['medium'] = $mediumSRC;
|
||||||
|
$meta['large'] = $largeSRC;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//preprint($exifs);
|
||||||
|
/*
|
||||||
|
$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>";
|
||||||
|
*/
|
||||||
|
//$meta = zp_query_exif( $zp_image ); //745 $meta['keywords'] =>
|
||||||
|
$exif_array = img_wp_exif( $meta ); //1214
|
||||||
|
//echo "exif_array";
|
||||||
|
//preprint($exif_array);
|
||||||
|
|
||||||
|
|
||||||
|
$links = (($caption != "") ? '<div id="flickr_' . $rnd . '" style="width: ' . ($w_mediumSRC + 10) . 'px" class="wp-caption aligncenter">' : '');
|
||||||
|
|
||||||
|
$links .= '<a href="' . $largeSRC . '" class="' . (($lb == true) ? $selector : '') . '"title="' . $title . '">';
|
||||||
|
$links .= '<img class="';
|
||||||
|
$links .= (($caption == "") ? 'aligncenter size-medium"' : '"');
|
||||||
|
|
||||||
|
//$links .= 'srcset="' . $zenphoto_url . 'cache/' . $album . '/' . $img . ' _' . $size . '_watermark.jpg, ' . $zenphoto_url . 'albums/' . $album . '/'. $image . ' 2x" alt="' . $img . '" />';
|
||||||
|
//$links .= 'srcset="' . $small . ', " ' . $flickr_size[3] . ' 2x" alt="' . $img . '" />';
|
||||||
|
$links .= 'srcset="' . $mediumSRC . ', ' . $largeSRC . ' 2x' . '" alt="' . $title . '" />';
|
||||||
|
|
||||||
|
$links .= '</a>';
|
||||||
|
|
||||||
$links .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
|
$links .= (($caption != "") ? '<p class="wp-caption-text">' . $caption . '</p></div>' : '');
|
||||||
|
|
||||||
|
$links .= "<div class='image-exif'>" . $exif_array[0] . (($display_gps == true) ? $exif_array[2] : '') . "</div>";
|
||||||
|
|
||||||
|
/*
|
||||||
|
$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);
|
||||||
|
$matches2 = array();
|
||||||
|
*/
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $links;
|
return $links;
|
||||||
}
|
}
|
||||||
add_filter( 'the_content', 'do_shortcode');
|
add_filter( 'the_content', 'do_shortcode');
|
||||||
@@ -715,7 +908,7 @@ Array
|
|||||||
}
|
}
|
||||||
$meta['keywords'] = $tags;
|
$meta['keywords'] = $tags;
|
||||||
}
|
}
|
||||||
|
//preprint($meta);
|
||||||
return $meta;
|
return $meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1001,7 +1194,7 @@ xdebug_start_trace('/Users/bruno/Sites', XDEBUG_TRACE_COMPUTERIZED);
|
|||||||
// Autres sources que WP et ZP
|
// Autres sources que WP et ZP
|
||||||
elseif (substr_count($ancien, 'jpg') > 0) {
|
elseif (substr_count($ancien, 'jpg') > 0) {
|
||||||
|
|
||||||
echo "court2: " . $court . "<br>";
|
//echo "court2: " . $court . "<br>";
|
||||||
$meta = creator_get_exif( $court );
|
$meta = creator_get_exif( $court );
|
||||||
//$flk_size = getimagesize(htmlentities($filename3));
|
//$flk_size = getimagesize(htmlentities($filename3));
|
||||||
/*
|
/*
|
||||||
@@ -1041,7 +1234,7 @@ add_action('the_content','addexif');
|
|||||||
|
|
||||||
|
|
||||||
function img_wp_exif( $exif_array ) {
|
function img_wp_exif( $exif_array ) {
|
||||||
|
//preprint($exif_array);
|
||||||
/*
|
/*
|
||||||
Array
|
Array
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -17,10 +17,14 @@ get_header();
|
|||||||
$coord = array();
|
$coord = array();
|
||||||
|
|
||||||
the_content();
|
the_content();
|
||||||
|
|
||||||
|
//preprint($coord);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php //echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>'; ?>
|
<?php //echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>'; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
jQuery(document).ready(function ($) { // wait until the document is ready
|
jQuery(document).ready(function ($) { // wait until the document is ready
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ ul.list_marker {
|
|||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
padding-right: 8px;
|
padding-right: 8px;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
list-style-image: url(images/monde.png);
|
list-style-image: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.list_marker li:hover {
|
.list_marker li:hover {
|
||||||
|
|||||||
Reference in New Issue
Block a user