Skip to content

Instantly share code, notes, and snippets.

@sunshinephotocart
Last active October 5, 2023 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunshinephotocart/c719f397fa548c3f948fe3351d11173e to your computer and use it in GitHub Desktop.
Save sunshinephotocart/c719f397fa548c3f948fe3351d11173e to your computer and use it in GitHub Desktop.
Show all EXIF/image meta on single image view (Sunshine 3)
add_action( 'sunshine_after_image', 'sunshine_exif_data' );
function sunshine_exif_data( $image ) {
$meta = wp_get_attachment_metadata( $image->get_id() );
$image_meta = $meta['image_meta']; // Get the meta data/EXIF from the image upload
foreach ( $image_meta as $key => $value ) {
if ( !empty( $value ) ) {
echo ucwords( $key ) . ': '; // Display key as label
if ( is_array( $value ) ) {
echo join( ', ', $value ); // Display array values comma separated, likely keywords
} else {
echo $value; // Display value normally
}
echo '<br />';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment