Created
July 26, 2018 06:01
-
-
Save jordymeow/22a365165c9757ed0014877c3fb4fbac to your computer and use it in GitHub Desktop.
WP/LR Sync: Synchronize a custom meta/field with EXIF/IPTC data
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( "wplr_add_media", 'myapp_update_media_meta', 10, 2 ); | |
add_action( "wplr_update_media", 'myapp_update_media_meta', 10, 2 ); | |
function myapp_update_media_meta( $mediaId, $galleryID ) { | |
global $wplr; | |
$image = wp_get_attachment_url( $mediaId ); | |
$size = getimagesize($image, $info); | |
if ( isset( $info['APP13'] ) ) { | |
$iptc = iptcparse( $info['APP13'] ); | |
if ( isset( $iptc["2#090"][0] ) ) | |
update_post_meta( $mediaId, 'city', $iptc["2#090"][0] ); | |
if ( isset( $iptc["2#101"][0] ) ) | |
update_post_meta( $mediaId, 'country', $iptc["2#101"][0] ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment