1er commit
1er version
This commit is contained in:
300
exclus/loop-attachment ok.php
Normal file
300
exclus/loop-attachment ok.php
Normal file
@@ -0,0 +1,300 @@
|
||||
<?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
|
||||
// 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;
|
||||
//echo $attachment->ID;
|
||||
$before_item = '<li>';
|
||||
$after_item = '</li>';
|
||||
$sep = ': ';
|
||||
$before_block = '<div class="bloc_exif" id="' . $attachment->ID . '"><ul>';
|
||||
$after_block = '</ul></div>';
|
||||
|
||||
$exif_list = $before_block;
|
||||
if ($metadata['image_meta']['latitude'])
|
||||
$latitude = $metadata['image_meta']['latitude'];
|
||||
if ($metadata['image_meta']['longitude'])
|
||||
$longitude = $metadata['image_meta']['longitude'];
|
||||
if ($metadata['image_meta']['latitude_ref'])
|
||||
$lat_ref = $metadata['image_meta']['latitude_ref'];
|
||||
if ($metadata['image_meta']['longitude_ref'])
|
||||
$lng_ref = $metadata['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 = ''; }
|
||||
//$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($metadata['image_meta']['aperture']))
|
||||
$exif_list .= $before_item . __('Aperture', 'twentyten-child') . $sep . "f/" . $metadata['image_meta']['aperture'] . $after_item;
|
||||
|
||||
// Shutter speed
|
||||
if (!empty($metadata['image_meta']['shutter_speed'])) {
|
||||
$exif_list .= $before_item . __('Shutter speed', 'twentyten-child') . $sep;
|
||||
if ((1 / $metadata['image_meta']['shutter_speed']) > 1) {
|
||||
$exif_list .= "1/";
|
||||
if ((number_format((1 / $metadata['image_meta']['shutter_speed']), 1)) == 1.3
|
||||
or number_format((1 / $metadata['image_meta']['shutter_speed']), 1) == 1.5
|
||||
or number_format((1 / $metadata['image_meta']['shutter_speed']), 1) == 1.6
|
||||
or number_format((1 / $metadata['image_meta']['shutter_speed']), 1) == 2.5) {
|
||||
$exif_list .= number_format((1 / $metadata['image_meta']['shutter_speed']), 1, '.', '') . " s" . $after_item;
|
||||
}
|
||||
else {
|
||||
$exif_list .= number_format((1 / $metadata['image_meta']['shutter_speed']), 0, '.', '') . " s" . $after_item;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$exif_list .= $metadata['image_meta']['shutter_speed']." s" . $after_item;
|
||||
}
|
||||
}
|
||||
// Focal length
|
||||
if (!empty($metadata['image_meta']['focal_length']))
|
||||
$exif_list .= $before_item . __('Focal length', 'twentyten-child') . $sep . $metadata['image_meta']['focal_length'] . " mm" . $after_item;
|
||||
// Camera
|
||||
if (!empty($metadata['image_meta']['camera']))
|
||||
$exif_list .= $before_item . __('Camera', 'twentyten-child') . $sep . $metadata['image_meta']['camera'] . $after_item;
|
||||
// Creation time
|
||||
if (!empty($metadata['image_meta']['created_timestamp']))
|
||||
$exif_list .= $before_item . __('Taken', 'twentyten-child') . $sep . date('j F, Y',$metadata['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;
|
||||
|
||||
$exif_list .= $after_block;
|
||||
|
||||
echo $exif_list;
|
||||
|
||||
// Titre du marker
|
||||
if ($metadata['image_meta']['caption']) $title_marker = $metadata['image_meta']['caption'];
|
||||
elseif ($metadata['file']) $title_marker = $metadata['file'];
|
||||
?>
|
||||
|
||||
|
||||
<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 $neg_lat . number_format($lat,6); ?>, <?php echo $neg_lng . number_format($lng, 6); ?>);
|
||||
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 $neg_lat . number_format($lat,6); ?></li>';
|
||||
html += '<li>Long: <?php echo $neg_lng . number_format($lng, 6); ?></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. ?>
|
||||
Reference in New Issue
Block a user