title: Wordpress wp_get_attachment_metadata() not working properly when called from plugin
body: <p>Im trying to use <code>wp_get_attachment_metadata()</code> function on a plugin. It is calling the function, and inside I try to fetch the metadata information of the attachment.</p>
  
  <pre><code>$file = wp_get_attachment_metadata( $attachment_id, false);
  </code></pre>
  
  <p>The problem is that this code is only returning the metadata for image files (png, jpg) even though the other file types are configured and are being uploaded properly. (I can see the other files in the media list, but, I can't access their metadata with this function).</p>
  
  <p>Please have a look at the code that grabs the metadata:</p>
  
  <pre><code>add_filter( 'fu_is_debug', '__return_true' );
  
  add_action( 'fu_after_upload', 'my_fu_after_upload', 10, 3 );
  function my_fu_after_upload( $attachment_ids, $success, $post_id ) {
      // do something with freshly uploaded files
      // This happens on POST request, so $_POST will also be available for you
      $dest_folder = "/exports/data/".$post_id;
  
      echo "FUNCTION AFTER UPLOAD: " . "&lt;br&gt;attachment_ids=";
      print_r($attachment_ids);
      echo "&lt;br&gt;result=". $success . "&lt;br&gt;post_id=". $post_id ;
      print_r($_POST);
  
      $post_name = get_post_field( 'post_title', $post_id, "");
      echo "Post name = " . $post_name . "&lt;br&gt;";
  
      if (!is_dir($dest_folder))
          mkdir($dest_folder);
      $upload_dir =  wp_upload_dir();
      echo "Upload dir&lt;br&gt;";
      print_r($upload_dir);
  
      foreach ($attachment_ids as $attachment_id) {
          printf("Getting attacments to atta %d &lt;br&gt;", $attachment_id);
          $file = wp_get_attachment_metadata( $attachment_id, false);
          print_r($file);
          echo "&lt;br&gt;";
          $file = $file['file'];
          $source_file = $upload_dir['basedir'] .'/'. $file;
          // Get the last name of the file, ie for /2013/07/file.img returns file.img
          $file = explode('/', $file);
          $file = $file[count($file) - 1];
          // Get the file extension
          $f_extension = explode('.', $file);
          if (count($f_extension) &lt; 2 ) {
              $f_extension = "";
          } else {
              $f_extension = $f_extension[count($f_extension) - 1];
          }
  
          $dest_file = $dest_folder . '/' . $_POST['ra'] . '.' . $f_extension;
  
          printf("Copying '%s' to '%s'&lt;br&gt;", $source_file, $dest_file);
          // TODO: Verificar se não existe o arquivo antes
          copy($source_file, $dest_file);
  
      }
      flush();
  }
  
  add_action('fu_upload_result', 'my_fu_upload_result', 10, 2 );
  function my_fu_upload_result( $layout, $result ) {
      // do something
      echo "FUNCTION UPLOAD RESULT: " . "&lt;br&gt;layout=" . $layout .
          "&lt;br&gt;result=". $result;
      print_r($_POST);
  
  }
  </code></pre>
  
  <p>Source: <a href="https://gist.github.com/sombrafam/426dad85eb390c9b6082" rel="nofollow">https://gist.github.com/sombrafam/426dad85eb390c9b6082</a></p>
  
  <p>The screen log of a image file:</p>
  
  <pre><code>FUNCTION AFTER UPLOAD: 
  attachment_ids=Array ( [0] =&gt; 121 ) 
  result=1
  post_id=32Array ( [post_ID] =&gt; 32 [post_title] =&gt; Erlon Cruz [ra] =&gt; 123456 [action] =&gt; upload_ugc [form_layout] =&gt; image [fu_nonce] =&gt; d71734168a [_wp_http_referer] =&gt; /?p=32 [ff] =&gt; f3c01b8520a3bdaf1f0141dd2b20f488 [form_post_id] =&gt; 32 ) Post name = Trabalho 1 - (ICA)
  Upload dir
  Array ( [path] =&gt; /var/www/wordpress/wp-content/uploads/2014/07 [url] =&gt; http://www.erloncruz.com.br/wp-content/uploads/2014/07 [subdir] =&gt; /2014/07 [basedir] =&gt; /var/www/wordpress/wp-content/uploads [baseurl] =&gt; http://www.erloncruz.com.br/wp-content/uploads [error] =&gt; ) Getting attacments to atta 121 
  Array ( [width] =&gt; 940 [height] =&gt; 168 [file] =&gt; 2014/07/banner1.png [sizes] =&gt; Array ( [thumbnail] =&gt; Array ( [file] =&gt; banner1-150x150.png [width] =&gt; 150 [height] =&gt; 150 [mime-type] =&gt; image/png ) [medium] =&gt; Array ( [file] =&gt; banner1-300x53.png [width] =&gt; 300 [height] =&gt; 53 [mime-type] =&gt; image/png ) ) [image_meta] =&gt; Array ( [aperture] =&gt; 0 [credit] =&gt; [camera] =&gt; [caption] =&gt; [created_timestamp] =&gt; 0 [copyright] =&gt; [focal_length] =&gt; 0 [iso] =&gt; 0 [shutter_speed] =&gt; 0 [title] =&gt; ) ) 
  Copying '/var/www/wordpress/wp-content/uploads/2014/07/banner1.png' to '/exports/data/32/123456.png'
  
  Notice: Array to string conversion in /var/www/wordpress/wp-content/plugins/frontend-uploader/lib/php/functions.php on line 312
  FUNCTION UPLOAD RESULT: 
  layout=image
  result=ArrayArray ( [post_ID] =&gt; 32 [post_title] =&gt; Erlon Cruz [ra] =&gt; 123456 [action] =&gt; upload_ugc [form_layout] =&gt; image [fu_nonce] =&gt; d71734168a [_wp_http_referer] =&gt; /?p=32 [ff] =&gt; f3c01b8520a3bdaf1f0141dd2b20f488 [form_post_id] =&gt; 32 ) 
  Warning: Cannot modify header information - headers already sent in /var/www/wordpress/wp-includes/pluggable.php on line 1121 
  </code></pre>
  
  <p>Source: <a href="https://gist.github.com/sombrafam/c3bea65068e4c1b3b039" rel="nofollow">https://gist.github.com/sombrafam/c3bea65068e4c1b3b039</a></p>
  
  <p>And a log of a pdf upload:</p>
  
  <pre><code>FUNCTION AFTER UPLOAD: 
  attachment_ids=Array ( [0] =&gt; 122 ) 
  result=1
  post_id=32Array ( [post_ID] =&gt; 32 [post_title] =&gt; Erlon Cruz [ra] =&gt; 123456 [action] =&gt; upload_ugc [form_layout] =&gt; image [fu_nonce] =&gt; d71734168a [_wp_http_referer] =&gt; /?p=32 [ff] =&gt; f3c01b8520a3bdaf1f0141dd2b20f488 [form_post_id] =&gt; 32 ) Post name = Trabalho 1 - (ICA)
  Upload dir
  Array ( [path] =&gt; /var/www/wordpress/wp-content/uploads/2014/07 [url] =&gt; http://www.erloncruz.com.br/wp-content/uploads/2014/07 [subdir] =&gt; /2014/07 [basedir] =&gt; /var/www/wordpress/wp-content/uploads [baseurl] =&gt; http://www.erloncruz.com.br/wp-content/uploads [error] =&gt; ) Getting attacments to atta 122 
  
  
  Warning: Illegal string offset 'file' in /var/www/wordpress/wp-content/plugins/frontend-uploader/lib/php/functions.php on line 285
  
  Notice: Uninitialized string offset: 0 in /var/www/wordpress/wp-content/plugins/frontend-uploader/lib/php/functions.php on line 285
  Copying '/var/www/wordpress/wp-content/uploads/' to '/exports/data/32/123456.'
  
  Warning: copy(): The first argument to copy() function cannot be a directory in /var/www/wordpress/wp-content/plugins/frontend-uploader/lib/php/functions.php on line 302
  
  Notice: Array to string conversion in /var/www/wordpress/wp-content/plugins/frontend-uploader/lib/php/functions.php on line 312
  FUNCTION UPLOAD RESULT: 
  layout=image
  result=ArrayArray ( [post_ID] =&gt; 32 [post_title] =&gt; Erlon Cruz [ra] =&gt; 123456 [action] =&gt; upload_ugc [form_layout] =&gt; image [fu_nonce] =&gt; d71734168a [_wp_http_referer] =&gt; /?p=32 [ff] =&gt; f3c01b8520a3bdaf1f0141dd2b20f488 [form_post_id] =&gt; 32 ) 
  Warning: Cannot modify header information - headers already sent in /var/www/wordpress/wp-includes/pluggable.php on line 1121
  </code></pre>
  
  <p>Source: <a href="https://gist.github.com/sombrafam/bfdd531bbfa97e34f28d" rel="nofollow">https://gist.github.com/sombrafam/bfdd531bbfa97e34f28d</a></p>