title: Wordpress wp_get_attachment_metadata
body: <p>I have a problem with some of my custom gallery functions, that I have used for years in WordPress.
  Now with WordPress Version 4.0 the <code>wp_get_attachment_metadata</code> function isn't working correctly, so that I have no alt-attribute. Everything else is working perfectly. Images are visible and in correct order.</p>
  
  <pre><code>&lt;!-- language: lang-php --&gt;
  
  /* CUSTOM GALLERY ############################################### */
  
  add_filter('post_gallery', 'my_post_gallery', 10, 2);
  function my_post_gallery($output, $attr) {
      global $post;
  
      if (isset($attr['orderby'])) {
          $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
          if (!$attr['orderby'])
              unset($attr['orderby']);
      }
  
      extract(shortcode_atts(array(
          'order' =&gt; 'ASC',
          'orderby' =&gt; 'menu_order ID',
          'id' =&gt; $post-&gt;ID,
          'itemtag' =&gt; 'dl',
          'icontag' =&gt; 'dt',
          'captiontag' =&gt; 'dd',
          'columns' =&gt; 3,
          'size' =&gt; 'thumbnail',
          'include' =&gt; '',
          'exclude' =&gt; ''
      ), $attr));
  
      $id = intval($id);
      if ('RAND' == $order) $orderby = 'none';
  
      if (!empty($include)) {
          $include = preg_replace('/[^0-9,]+/', '', $include);
          $_attachments = get_posts(array('include' =&gt; $include, 'post_status' =&gt; 'inherit',
          'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'order' =&gt; $order,
          'orderby' =&gt; $orderby));
  
          $attachments = array();
          foreach ($_attachments as $key =&gt; $val) {
              $attachments[$val-&gt;ID] = $_attachments[$key];
          }
      }
  
      if (empty($attachments)) return '';
  
      $output = "&lt;div class=\"slideshow-wrapper\"&gt;\n";
      $output .= "&lt;div class=\"preloader\"&gt;&lt;/div&gt;\n";
      $output .= "&lt;ul data-orbit&gt;\n";
  
      foreach ($attachments as $id =&gt; $attachment) {
          $img = wp_get_attachment_image_src($id, 'full');
          $image_data = wp_get_attachment_metadata($id, FALSE );
          $output .= "&lt;li&gt;\n";
          $output .= "&lt;img src=\"\" data-src=\"{$img[0]}\" width=\"{$img[1]}\" 
          height=\"{$img[2]}\" alt=\"{$image_data['image_meta']['title']}\" 
          class=\"gallery-img\"/&gt;&lt;noscript&gt;&lt;img src=\"{$img[0]}\" 
          data-src=\"{$img[0]}\" width=\"{$img[1]}\" height=\"{$img[2]}\"
          alt=\"{$image_data['image_meta']['description']}\" 
          class=\"gallery-img\"\&gt;&lt;/noscript&gt;";
          $output .= "&lt;/li&gt;\n";
      }
  
      $output .= "&lt;/ul&gt;\n";
      $output .= "&lt;/div&gt;\n";
  
      return $output;
  }
  </code></pre>