/**
  * Copy attachment metadata to duplicated items
  *
  * This filter is called AFTER MLA mapping rules are applied during
  * wp_update_attachment_metadata() processing. The postfilter gives you
  * an opportunity to record or update the metadata after the mapping.
  *
  * @since 2.20
  *
  * @param	array	attachment metadata
  * @param	integer	The Post ID of the new/updated attachment
  * @param	array	Processing options, e.g., 'is_upload'
  *
  * @return	array	updated attachment metadata
  */
 public static function mla_update_attachment_metadata_postfilter($data, $post_id, $options)
 {
     $uploading = var_export(!empty($options['is_upload']), true);
     $duplicating = var_export(self::$updating_duplicates, true);
     MLACore::mla_debug_add(__LINE__ . " MLA_WPML::mla_update_attachment_metadata_postfilter( {$post_id}, {$uploading}, {$duplicating} ) data = " . var_export($data, true), MLACore::MLA_DEBUG_CATEGORY_LANGUAGE);
     if (!empty($options['is_upload']) && !self::$updating_duplicates) {
         /*
          * If always_translate_media is set there will be translations present
          * that have no attachment metadata and have not been mapped.
          */
         if (!empty(self::$duplicate_attachments)) {
             self::$updating_duplicates = true;
             foreach (self::$duplicate_attachments as $id => $language) {
                 $meta = get_post_meta($id, '_wp_attachment_metadata', true);
                 MLACore::mla_debug_add(__LINE__ . " MLA_WPML::mla_update_attachment_metadata_postfilter( {$id}, {$language} ) attachment_metadata = " . var_export($meta, true), MLACore::MLA_DEBUG_CATEGORY_LANGUAGE);
                 if (is_array($meta)) {
                     continue;
                 }
                 /*
                  * update_post_meta is required twice; first to set it for mapping rules,
                  * second to repair the damage done by WPML synchronize_attachment_metadata
                  */
                 update_post_meta($id, '_wp_attachment_metadata', $data);
                 MLAOptions::mla_add_attachment_action($id);
                 MLAOptions::mla_update_attachment_metadata_filter($data, $id);
                 update_post_meta($id, '_wp_attachment_metadata', $data);
                 $meta = get_post_meta($id, '_wp_attachment_metadata', false);
                 MLACore::mla_debug_add(__LINE__ . " MLA_WPML::mla_update_attachment_metadata_postfilter( {$id}, {$language} ) attachment_metadata = " . var_export($meta, true), MLACore::MLA_DEBUG_CATEGORY_LANGUAGE);
             }
             self::$updating_duplicates = false;
         }
     }
     return $data;
 }