320 lines
12 KiB
PHP
320 lines
12 KiB
PHP
<?php
|
|
/**
|
|
* The loop that displays an attachment.
|
|
*
|
|
* The loop displays the posts and the post content. See
|
|
* http://codex.wordpress.org/The_Loop to understand it and
|
|
* http://codex.wordpress.org/Template_Tags to understand
|
|
* the tags used in it.
|
|
*
|
|
* This can be overridden in child themes with loop-attachment.php.
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Twenty_Ten
|
|
* @since Twenty Ten 1.2
|
|
*/
|
|
?>
|
|
|
|
<?php
|
|
|
|
|
|
function ListeExif($meta, $attach){
|
|
$before_item = '<li>';
|
|
$after_item = '</li>';
|
|
$sep = ': ';
|
|
$zoom = '11';
|
|
|
|
if ($meta['image_meta']['latitude'])
|
|
$latitude = $meta['image_meta']['latitude'];
|
|
if ($meta['image_meta']['longitude'])
|
|
$longitude = $meta['image_meta']['longitude'];
|
|
if ($meta['image_meta']['latitude_ref'])
|
|
$lat_ref = $meta['image_meta']['latitude_ref'];
|
|
if ($meta['image_meta']['longitude_ref'])
|
|
$lng_ref = $meta['image_meta']['longitude_ref'];
|
|
|
|
$lat = geo_single_fracs2dec($latitude);
|
|
$lng = geo_single_fracs2dec($longitude);
|
|
|
|
if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; }
|
|
if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
|
|
|
|
$gm_lat = $neg_lat . number_format($lat,6);
|
|
$gm_lng = $neg_lng . number_format($lng, 6);
|
|
|
|
//$start_geo_link = '<a href="http://maps.google.com/maps?q=' . $neg_lat . number_format($lat,6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11">';
|
|
$start_geo_link = '<a href="http://maps.google.com/maps?q=' . $neg_lat . number_format($lat,6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11">';
|
|
//$jquery_geo_link = 'http://maps.google.com/maps?q=' . $neg_lat . number_format($lat,6) . '+' . $neg_lng . number_format($lng, 6) . '&z=11';
|
|
$end_geo_link = '</a>';
|
|
|
|
// Aperture
|
|
if (!empty($meta['image_meta']['aperture']))
|
|
$exif_list .= $before_item . __('Aperture', 'twentyten-child') . $sep . "f/" . $meta['image_meta']['aperture'] . $after_item;
|
|
|
|
// Shutter speed
|
|
if (!empty($meta['image_meta']['shutter_speed'])) {
|
|
$exif_list .= $before_item . __('Shutter speed', 'twentyten-child') . $sep;
|
|
if ((1 / $meta['image_meta']['shutter_speed']) > 1) {
|
|
$exif_list .= "1/";
|
|
if ((number_format((1 / $meta['image_meta']['shutter_speed']), 1)) == 1.3
|
|
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 1.5
|
|
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 1.6
|
|
or number_format((1 / $meta['image_meta']['shutter_speed']), 1) == 2.5) {
|
|
$exif_list .= number_format((1 / $meta['image_meta']['shutter_speed']), 1, '.', '') . " s" . $after_item;
|
|
}
|
|
else {
|
|
$exif_list .= number_format((1 / $meta['image_meta']['shutter_speed']), 0, '.', '') . " s" . $after_item;
|
|
}
|
|
}
|
|
else {
|
|
$exif_list .= $meta['image_meta']['shutter_speed']." s" . $after_item;
|
|
}
|
|
}
|
|
// Focal length
|
|
if (!empty($meta['image_meta']['focal_length']))
|
|
$exif_list .= $before_item . __('Focal length', 'twentyten-child') . $sep . $meta['image_meta']['focal_length'] . " mm" . $after_item;
|
|
// Camera
|
|
if (!empty($meta['image_meta']['camera']))
|
|
$exif_list .= $before_item . __('Camera', 'twentyten-child') . $sep . $meta['image_meta']['camera'] . $after_item;
|
|
// Creation time
|
|
if (!empty($meta['image_meta']['created_timestamp']))
|
|
$exif_list .= $before_item . __('Taken', 'twentyten-child') . $sep . date('j F, Y',$meta['image_meta']['created_timestamp']) . $after_item;
|
|
|
|
// Latitude and Longtitude
|
|
if ($latitude != 0 && $longitude != 0)
|
|
//affichage dans un cadre map caché
|
|
//$exif_list .= $before_item . '<div onclick="toggleExif(\'map\');" ><image src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" /></div>' . $after_item;
|
|
$exif_list .= $before_item . '<image onclick="toggleExif(\'map\');" src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />' . $after_item;
|
|
// jquery
|
|
//$exif_list .= $before_item . '<a id="map_link" href="#"><image src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" /></a>' . $after_item;
|
|
|
|
//affichage map dans nouvelle fenetre
|
|
//$exif_list .= $before_item . $start_geo_link . '<image src="' . get_stylesheet_directory_uri() . '/images/monde.png" width="16" height="16" />' . $end_geo_link . $after_item;
|
|
|
|
// Titre du marker
|
|
if ($meta['image_meta']['caption']) $title_marker = $meta['image_meta']['caption'];
|
|
elseif ($meta['file']) $title_marker = $meta['file'];
|
|
|
|
return array($exif_list, $gm_lat, $gm_lng, $title_marker);
|
|
}
|
|
|
|
// return geo exif in a nice form
|
|
/*
|
|
function geo_frac2dec($str) {
|
|
@list( $n, $d ) = explode( '/', $str );
|
|
if ( !empty($d) )
|
|
return $n / $d;
|
|
return $str;
|
|
}
|
|
|
|
function geo_pretty_fracs2dec($fracs) {
|
|
return geo_frac2dec($fracs[0]) . '° ' .
|
|
geo_frac2dec($fracs[1]) . '′ ' .
|
|
geo_frac2dec($fracs[2]) . '″ ';
|
|
}
|
|
|
|
function geo_single_fracs2dec($fracs) {
|
|
return geo_frac2dec($fracs[0]) +
|
|
geo_frac2dec($fracs[1]) / 60 +
|
|
geo_frac2dec($fracs[2]) / 3600;
|
|
}
|
|
*/
|
|
?>
|
|
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
|
|
|
|
<?php if ( ! empty( $post->post_parent ) ) : ?>
|
|
<div id="nav-above" class="navigation">
|
|
<div class="nav-previous"><a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php esc_attr( printf( __( 'Return to %s', 'twentyten' ), get_the_title( $post->post_parent ) ) ); ?>" rel="gallery"><?php
|
|
/* translators: %s - title of parent post */
|
|
printf( __( '<span class="meta-nav">←</span> %s', 'twentyten' ), get_the_title( $post->post_parent ) );
|
|
?></a></div>
|
|
</div><!-- #nav-above -->
|
|
<?php endif; ?>
|
|
|
|
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
|
<h1 class="entry-title"><?php the_title(); ?></h1>
|
|
|
|
<div class="entry-meta">
|
|
<?php
|
|
printf( __( '%1$s', 'twentyten-child' ),
|
|
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
|
|
get_permalink(),
|
|
esc_attr( get_the_time() ),
|
|
get_the_date()
|
|
)
|
|
);
|
|
if ( wp_attachment_is_image() ) {
|
|
echo ' <span class="meta-sep">|</span> ';
|
|
$metadata = wp_get_attachment_metadata();
|
|
printf( __( 'Full size is %s pixels', 'twentyten' ),
|
|
sprintf( '<a href="%1$s" title="%2$s">%3$s × %4$s</a>',
|
|
wp_get_attachment_url(),
|
|
esc_attr( __( 'Link to full-size image', 'twentyten' ) ),
|
|
$metadata['width'],
|
|
$metadata['height']
|
|
)
|
|
);
|
|
}
|
|
?>
|
|
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
|
|
</div><!-- .entry-meta -->
|
|
|
|
<div class="entry-content">
|
|
<div class="entry-attachment">
|
|
<?php if ( wp_attachment_is_image() ) :
|
|
$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
|
|
foreach ( $attachments as $k => $attachment ) {
|
|
if ( $attachment->ID == $post->ID )
|
|
break;
|
|
}
|
|
$k++;
|
|
// If there is more than 1 image attachment in a gallery
|
|
if ( count( $attachments ) > 1 ) {
|
|
if ( isset( $attachments[ $k ] ) )
|
|
// get the URL of the next image attachment
|
|
$next_attachment_url = get_attachment_link( $attachments[ $k ]->ID );
|
|
else
|
|
// or get the URL of the first image attachment
|
|
$next_attachment_url = get_attachment_link( $attachments[ 0 ]->ID );
|
|
} else {
|
|
// or, if there's only 1 image attachment, get the URL of the image
|
|
$next_attachment_url = wp_get_attachment_url();
|
|
}
|
|
?>
|
|
<p class="attachment"><a href="<?php echo $next_attachment_url; ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php
|
|
$attachment_width = apply_filters( 'twentyten_attachment_size', 900 );
|
|
$attachment_height = apply_filters( 'twentyten_attachment_height', 900 );
|
|
echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height.
|
|
?></a></p>
|
|
|
|
|
|
|
|
|
|
|
|
<?php else : ?>
|
|
<a href="<?php echo wp_get_attachment_url(); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php echo basename( get_permalink() ); ?></a>
|
|
|
|
<?php endif; ?>
|
|
<!-- .entry-attachment -->
|
|
<div class="entry-caption"><?php if ( !empty( $post->post_excerpt ) ) the_excerpt(); ?>
|
|
</div><!-- .entry-caption -->
|
|
|
|
|
|
|
|
|
|
<div class="droite" onclick="toggleExif(<?php echo $attachment->ID; ?>);">Voir les Exif</div>
|
|
|
|
|
|
<?php //print_r($metadata); ?>
|
|
|
|
<?php
|
|
//$geo_links = true;
|
|
$attach = $attachment->ID;
|
|
|
|
//echo $attachment->ID;
|
|
$before_block = '<div class="bloc_exif" id="' . $attach . '"><ul>';
|
|
$after_block = '</ul></div><!-- .bloc_exif -->';
|
|
$liste_exif = $before_block;
|
|
|
|
list($exif_list, $gm_lat, $gm_lng, $title_marker) = ListeExif($metadata, $attach);
|
|
|
|
$liste_exif .= $exif_list;
|
|
$liste_exif .= $after_block;
|
|
|
|
echo $liste_exif;
|
|
|
|
?>
|
|
|
|
|
|
<div id="map"></div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
//var latlng = new google.maps.LatLng(47.087170, 6.713577);
|
|
/**/
|
|
var contentString = "<?php echo $title_marker; ?>";
|
|
var curr_infw;
|
|
var latlng = new google.maps.LatLng(<?php echo $gm_lat; ?>, <?php echo $gm_lng; ?>);
|
|
var myOptions = {
|
|
/* http://code.google.com/intl/fr/apis/maps/documentation/javascript/reference.html#MapOptions */
|
|
zoom: 11,
|
|
center: latlng,
|
|
scrollwheel: true,
|
|
scaleControl: false,
|
|
disableDefaultUI: false,
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP
|
|
/*
|
|
navigationControl: true,
|
|
navigationControlOptions: {
|
|
style: google.maps.NavigationControlStyle.SMALL
|
|
}*/
|
|
};
|
|
var map = new google.maps.Map(document.getElementById("map"), myOptions);
|
|
|
|
marker = createMarker(latlng, '', contentString, map);
|
|
|
|
function createMarker(point, title, content, map) {
|
|
var myMarkerImage = new google.maps.MarkerImage('http://maps.google.com/mapfiles/arrow.png');
|
|
var myMarkerShadow = new google.maps.MarkerImage('http://maps.google.com/mapfiles/arrowshadow.png');
|
|
var marker = new google.maps.Marker({
|
|
position: point,
|
|
map: map,
|
|
icon: myMarkerImage,
|
|
shadow: myMarkerShadow,
|
|
title: title
|
|
});
|
|
var infowindow = new google.maps.InfoWindow({
|
|
//content: content
|
|
content: createInfo(content,content),
|
|
//width: 500,
|
|
//height: 400
|
|
});
|
|
|
|
google.maps.event.addListener(marker, 'click', function() { /* mouseover */
|
|
if(curr_infw) { curr_infw.close();} // We check to see if there is an info window stored in curr_infw, if there is, we use .close() to hide the window
|
|
curr_infw = infowindow; // Now we put our new info window in to the curr_infw variable
|
|
infowindow.open(map, marker); // Now we open the window
|
|
});
|
|
return marker;
|
|
};
|
|
|
|
// Create information window
|
|
function createInfo(title, content) {
|
|
var html = '<div class="infowindow">';
|
|
html += '<strong>'+ title +'</strong>';
|
|
html += '<p>'+content+'</p>';
|
|
html += '<ul><li>Lat: <?php echo $gm_lat; ?></li>';
|
|
html += '<li>Long: <?php echo $gm_lng; ?></li>';
|
|
html += '</div>';
|
|
return html;
|
|
}
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
|
|
</div><!-- .entry-attachment -->
|
|
|
|
<!--p>Description</p-->
|
|
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?>
|
|
|
|
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
|
|
|
|
<div id="nav-below" class="navigation">
|
|
<div class="nav-previous"><?php previous_image_link( false ); ?></div>
|
|
<div class="nav-next"><?php next_image_link( false ); ?></div>
|
|
</div><!-- #nav-below -->
|
|
|
|
</div><!-- .entry-content -->
|
|
|
|
<div class="entry-utility">
|
|
<?php twentyten_posted_in(); ?>
|
|
<?php edit_post_link( __( 'Edit', 'twentyten' ), ' <span class="edit-link">', '</span>' ); ?>
|
|
</div><!-- .entry-utility -->
|
|
</div><!-- #post-## -->
|
|
|
|
<?php comments_template(); ?>
|
|
|
|
<?php endwhile; // end of the loop. ?>
|