/** * Extract IPTC info from original source image * Save IPTC data as custom taxonomy terms */ public function parse_iptc_info($original_file = null, $attachment_id = null) { // Extract IPTC meta info from the uploaded image. $city = sell_media_iptc_parser('city', $original_file); $state = sell_media_iptc_parser('state', $original_file); $creator = sell_media_iptc_parser('creator', $original_file); $keywords = sell_media_iptc_parser('keywords', $original_file); global $post; $product_id = empty($post->ID) ? get_post_meta($attachment_id, '_sell_media_for_sale_product_id', true) : $post->ID; // Save IPTC info as taxonomies if (!empty($product_id)) { if ($city) { sell_media_iptc_save('city', $city, $product_id); } if ($state) { sell_media_iptc_save('state', $state, $product_id); } if ($creator) { sell_media_iptc_save('creator', $creator, $product_id); } if ($keywords) { sell_media_iptc_save('keywords', $keywords, $product_id); } } }
/** * Extract IPTC info from original source image * Save IPTC data as custom taxonomy terms */ public function parse_iptc_info($original_file = null, $attachment_id = null) { global $post; // Extract IPTC meta info from the uploaded image. $city = sell_media_iptc_parser('city', $original_file); $state = sell_media_iptc_parser('state', $original_file); $creator = sell_media_iptc_parser('creator', $original_file); $keywords = sell_media_iptc_parser('keywords', $original_file); /** * Assign terms to either the post or the attachment. * * In version 2.0, we added the product gallery capabilty. * Since multiple images can be assigned, taxonomy terms (keywords) * should be assigned to the attachments, not the post. */ if (!sell_media_has_multiple_attachments($post->ID)) { $attachment_id = $post->ID; } // Save IPTC info as taxonomies if (!empty($attachment_id)) { if ($city) { sell_media_iptc_save('city', $city, $attachment_id); } if ($state) { sell_media_iptc_save('state', $state, $attachment_id); } if ($creator) { sell_media_iptc_save('creator', $creator, $attachment_id); } if ($keywords) { sell_media_iptc_save('keywords', $keywords, $attachment_id); } } }