title: Wordpress posting featured image to Twitter
body: <p>I have a Photo/Wordpress site where each of my posts consist of a featured image. What i'm trying to create is to automatically post the uploaded featured image to Twitter after publishing the post. I managed to add a function to Functions.php that executes when publishing a post.</p>
  
  <pre><code>add_action('publish_post','postToTwitter');
  </code></pre>
  
  <p>The postToTwitter function creates a tweet with Matt Harris OAuth 1.0A library.
  This works fine if i attach an image that's relative to the file of the postToTwitter function.</p>
  
  <pre><code>// this is the jpeg file to upload. It should be in the same directory as this file.
  $image = dirname(__FILE__) . '/image.jpg';
  </code></pre>
  
  <p>So i want the $image var to hold my Featured Image i uploaded to the Wordpress post.</p>
  
  <p>But this doesn't work by just adding the URL from the uploaded image (since Wordpress upload folder is not relative to the file of the postToTwitter function):
  The update with media endpoint(Twitter) only supports images directly uploaded in the POST -- it will not take a remote URL as an argument.</p>
  
  <p>So my question is how i can refer to the Featured Image uploaded in the POST?</p>
  
  <pre><code>// This is how it should work with an image upload form
  $image = "@{$_FILES['image']['tmp_name']};type={$_FILES['image']['type']};filename={$_FILES['image']['name']}"
  </code></pre>