I have a Photo / Wordpress site where each of my posts consists of a tag. What I'm trying to create is to automatically post the downloaded favorite image to Twitter after the publication of the publication. I managed to add the Functions.php function, which is executed when the publication is published.
add_action('publish_post','postToTwitter');
The postToTwitter function creates a tweet with the Matt Harris OAuth 1.0A library. This works fine if I attach an image related to the file of the postToTwitter function.
// this is the jpeg file to upload. It should be in the same directory as this file. $image = dirname(__FILE__) . '/image.jpg';
So, I want $ image var to store my Featured Image, which I uploaded to a Wordpress post.
But this does not work, simply adding the URL from the downloaded image (since the Wordpress download folder does not apply to the postToTwitter function file): The update with the media endpoint (Twitter) only supports images directly uploaded to POST - it will not accept as an argument remote URL.
So my question is, how can I link to Featured Image uploaded to POST?
// This is how it should work with an image upload form $image = "@{$_FILES['image']['tmp_name']};type={$_FILES['image']['type']};filename={$_FILES['image']['name']}"
Dylan source share