Last active
October 5, 2023 18:59
-
-
Save sunshinephotocart/c719f397fa548c3f948fe3351d11173e to your computer and use it in GitHub Desktop.
Show all EXIF/image meta on single image view (Sunshine 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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