Les métadonnées EXIF comprennent le crédit, l’appareil photo, la longueur focale, l’ouverture, l’iso, la vitesse d’obturation, l’horodatage, le copyright, etc. Vous pouvez afficher ces métadonnées EXIF avec vos images dans la médiathèque de WordPress.
Instructions : Ajoutez le code suivant au fichier functions.php de votre thème WordPress.
add_filter('manage_media_columns', 'posts_columns_attachment_exif', 1); add_action('manage_media_custom_column', 'posts_custom_columns_attachment_exif', 1, 2); function posts_columns_attachment_exif($defaults){ $defaults['wps_post_attachments_exif'] = __('EXIF'); return $defaults; } function posts_custom_columns_attachment_exif($column_name, $id){ if($column_name === 'wps_post_attachments_exif'){ $meta = wp_get_attachment_metadata($id); if($meta[image_meta][camera] != ''){ echo "CR: ".$meta[image_meta][credit]."<hr />"; echo "CAM: ".$meta[image_meta][camera]."<hr />"; echo "FL: ".$meta[image_meta][focal_length]."<hr />"; echo "AP: ".$meta[image_meta][aperture]."<hr />"; echo "ISO: ".$meta[image_meta][iso]."<hr />"; echo "SS: ".$meta[image_meta][shutter_speed]."<hr />"; echo "TS: ".$meta[image_meta][created_timestamp]."<hr />"; echo "C: ".$meta[image_meta][copyright]; } } }
Vous pouvez également apprécier la suppression de la méta-boîte de l’image vedette.
Made a few minor changes to prevent notices, and changed the HR to |
—-
function posts_custom_columns_attachment_exif($column_name, $id){
if($column_name === ‘wps_post_attachments_exif’){
$meta = wp_get_attachment_metadata($id);
if(isset($meta[‘image_meta’][‘camera’])){
echo “CR: ” . $meta[‘image_meta’][‘credit’] .’ | ‘;
echo “CAM: ” . $meta[‘image_meta’][‘camera’] .’ | ‘;
echo “FL: ” . $meta[‘image_meta’][‘focal_length’] . ‘ | ‘;
echo “AP: ” . $meta[‘image_meta’][‘aperture’] .’ | ‘;
echo “ISO: ” . $meta[‘image_meta’][‘iso’] . ‘ | ‘;
echo “SS: ” . $meta[‘image_meta’][‘shutter_speed’] . ‘ | ‘;
echo “TS: ” . $meta[‘image_meta’][‘created_timestamp’] . ‘ | ‘;
echo “C: ” . $meta[‘image_meta’][‘copyright’] : ‘N/A’ );
}
}
}
Any way to get this to show up every time with an image? Maybe make this automatically inserted into the description field?
great snippets, a little big for admin, but can we use it in our blog when we are over the picture?
It is a little big but could be adjusted with css. In regards to this snippet you can display things within your page using a similar method as $meta = wp_get_attachment_metadata($id); will get the meta data you just need to pass the attachment id. Ill make a post in the near future to display these details with your pictures.
Ok, thanks for your reply.
And thanks for the next posts
Hi, did you delete the snippset for the post?