Zaubertrank der 2. intus und morgen werde ich Jemand anderes sein. www.lebenamlimit.de #ipct #chemo #eiskappe #hyperthermie #badaibling #zaubertrank (hier: Kurpark Bad Aibling)

seen from Italy

seen from Singapore
seen from China

seen from United States
seen from Yemen
seen from United Kingdom
seen from United Kingdom

seen from Malaysia
seen from United States

seen from Italy
seen from United States
seen from Yemen

seen from United States
seen from Estonia

seen from United States

seen from Morocco

seen from Malaysia

seen from United States

seen from United States

seen from Malaysia
Zaubertrank der 2. intus und morgen werde ich Jemand anderes sein. www.lebenamlimit.de #ipct #chemo #eiskappe #hyperthermie #badaibling #zaubertrank (hier: Kurpark Bad Aibling)
Geotagging photos in Wordpress
A partire dalla versione 2.5 Wordpress supporta l'estrazione dei dati EXIF e IPCT dall'header delle foto. Per visualizzare queste informazioni bisogna creare il proprio template file single.php o image.php all'interno della cartella del tema in uso ed aggiungere alcuni frammenti di codice che vedremo qui di seguito.
Nel codice core di Wordpress non tutte le informazioni EXIF e IPCT vengono prelevate dalla foto, in particolare mi sto riferendo alle informazioni di geolocalizzazione. Per poter recuperare queste foto bisogna aggiungere il seguente filtro alla funzione wp_read_image_metadata, quindi aggiungere il codice qui sotto al file function.php (che si trova dentro alla cartella del tema in uso, se non c'è creare il file):
add_filter('wp_read_image_metadata', 'saveGeoExif','',3); function saveGeoExif($meta,$file) { $exif = @exif_read_data($file); if (isset($exif['GPSLatitude'])){ $meta['GPSLatitude'] = $exif['GPSLatitude']; } if (isset($exif['GPSLatitudeRef'])){ $meta['GPSLatitudeRef'] = trim($exif['GPSLatitudeRef']); } if (isset($exif['GPSLongitude'])){ $meta['GPSLongitude'] = $exif['GPSLongitude'] ; } if (isset($exif['GPSLongitudeRef'])){ $meta['GPSLongitudeRef'] = trim($exif['GPSLongitudeRef']); } if (isset($exif['GPSAltitudeRef'])){ $meta['GPSAltitudeRef'] = trim($exif['GPSLongitudeRef']); } if (isset($exif['GPSAltitude'])){ $meta['GPSAltitude'] = trim($exif['GPSLongitudeRef']); } if (isset($exif['GPSTimeStamp'])){ $meta['GPSTimeStamp'] = $exif['GPSLongitudeRef']; } if (isset($exif['GPSDOP'])){ $meta['GPSDOP'] = $exif['GPSLongitudeRef']; } if (isset($exif['GPSImgDirectionRef'])){ $meta['GPSImgDirectionRef'] = trim($exif['GPSLongitudeRef']); } if (isset($exif['GPSImgDirection'])){ $meta['GPSImgDirection'] = trim($exif['GPSLongitudeRef']); } return $meta; }
In questo modo ogni volta che viene caricata una foto, verranno salvate nel database anche tutte queste informazioni di posizione.
Ora vediamo come visualizzare queste informazioni. All'interno del file single.php o image.php aggiungiamo quanto segue. Per prima cosa vanno inserite queste due funzioni per poter convertire nel formato corretto longitudine e latitudine.
function fractionResult($fraction){ list($sup, $sub) = explode('/', $fraction); if(floatval($sub) != 0){ return $sup / $sub; }else{ return 0; } } function getCoord($fractional, $ref){ $coord = 0; if(is_array($fractional)){ $coord = fractionResult($fractional[0]) + fractionResult($fractional[1]) / 60 + fractionResult($fractional[2]) / 3600; } if($ref == "S" || $ref == "W"){ $coord = -$coord; } return $coord; }
Ora dobbiamo recuperare l'ID di tutte le foto allegate (attachments) ad un post.
// Recupera tutte le foto allegate al post $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts( $args );
A questo punto iteriamo su tutte le foto ed eseguiamo la funzione che ci permette di recuperare i metadati di cui abbiamo bisogno.
if ( $attachments ) { foreach ( $attachments as $attachment ) { $imgmeta = wp_get_attachment_metadata( $attachment->ID ); // Convert the shutter speed retrieve from database to fraction if ((1 / $imgmeta['image_meta']['shutter_speed']) > 1) { if ((number_format((1 / $imgmeta['image_meta']['shutter_speed']), 1)) == 1.3 or number_format((1 / $imgmeta['image_meta']['shutter_speed']), 1) == 1.5 or number_format((1 / $imgmeta['image_meta']['shutter_speed']), 1) == 1.6 or number_format((1 / $imgmeta['image_meta']['shutter_speed']), 1) == 2.5){ $pshutter = "1/" . number_format((1 / $imgmeta['image_meta']['shutter_speed']), 1, '.', '') . " second"; } else { $pshutter = "1/" . number_format((1 / $imgmeta['image_meta']['shutter_speed']), 0, '.', '') . " second"; } } else { $pshutter = $imgmeta['image_meta']['shutter_speed'] . " seconds"; } // Convert latitude and longitude if(isset($imgmeta['image_meta']['GPSLatitude'])) $lat = getCoord($imgmeta['image_meta']['GPSLatitude'], $imgmeta['image_meta']['GPSLatitudeRef']); if(isset($imgmeta['image_meta']['GPSLongitude'])) $long = getCoord($imgmeta['image_meta']['GPSLongitude'], $imgmeta['image_meta']['GPSLongitudeRef']); // Start to display EXIF and IPTC data of digital photograph echo "Date Taken: ".date("d-M-Y H:i:s", floatval($imgmeta['image_meta']['created_timestamp']))."<br />"; echo "Copyright: ".$imgmeta['image_meta']['copyright']."<br />"; echo "Credit: ".$imgmeta['image_meta']['credit']."<br />"; echo "Title: ".$imgmeta['image_meta']['title']."<br />"; echo "Caption: ".$imgmeta['image_meta']['caption']."<br />"; echo "Camera: ".$imgmeta['image_meta']['camera']."<br />"; echo "Focal Length: ".$imgmeta['image_meta']['focal_length']."mm<br />"; echo "Aperture: f/".$imgmeta['image_meta']['aperture']."<br />"; echo "ISO: ".$imgmeta['image_meta']['iso']."<br />"; echo "Shutter Speed: ".$pshutter."<br />"; echo "Latitude: ".$lat."<br />"; echo "Longitude: ".$long."<br />"; } }
Eccovi qui i link ai tutorial che mi hanno illuminato il buio sentiero della geolocalizzazione delle foto in Wordpres.
http://www.walkernews.net/2009/04/13/turn-on-wordpress-feature-to-display-photo-exif-data-and-iptc-information http://www.lucianmarica.com/stuff/geotagging-from-image-exif-data-in-wordpress
Con questo è tutto per oggi. Bye bye, Rob