title: How to rename a file while uploading an image in Wordpress gallery while keeping image metadata
body: <p>I'm trying to change file name, alt and description during upload getting data from post where I'm in.
  I have a problem with image metadata, which isn't correctly generate and store in database. I trying using WP functions to regenerate meta data during upload:</p>
  <pre><code>wp_generate_attachment_metadata( $attach_id, $savePath );
  wp_update_attachment_metadata( $attach_id, $a );
  </code></pre>
  <p>But these functions not working. Any data not sending into DB. This is a problem, because images don't have dimensions etc.</p>
  <p>My function:
  <a href="https://pastebin.com/TQB2sjjU" rel="nofollow noreferrer">https://pastebin.com/TQB2sjjU</a></p>