Support » Plugin: Twitter posts to Blog » Add featured image to all tweets

  • Resolved closer01


    Hi, you have great plugin. But it only add featured image when there is photo in the tweet by $media->media_url. I want to add to all tweet post featured image from external url. how i can do this, or how i can remove conditional if there is photo it adds. I want to use it like below.

    $image_url = ‘’; // Define the image URL here
    $upload_dir = wp_upload_dir(); // Set upload folder
    $image_data = file_get_contents($image_url); // Get image data

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author badbreze


    hmmm disable the set thumbnail image from configuration next on your theme or custom plugin or whathever you want add an action like this:

    function dg_tw_custom_image_for_tweets($post_id) {
        $fake_tweet = (object) array(
            'entities' => (object) array(
                'media' => array(
                    0 => (object) array(
                        'media_url' => YOUR_IMAGE_URL_HERE,
                        'media_url_https' => YOUR_IMAGE_URL_HERE,
                        'type' => 'photo'
        $images_list = dg_tw_insert_attachments($fake_tweet,$post_id);
        set_post_thumbnail( $post_id, end($images_list['ids']) );

    i dont know if it work, i havent tested =O

    EDIT: fixed, work for me

    Thank you for your answer, i am sure its working. but i am not good with php. So which page of your plugin i need to add this code? Because i want to set feature image for all tweet posts when there is no media too.

    I added to functions.php of your plugin. but nothing changed.

    Can u explain little more … Thank you

    Plugin Author badbreze


    hmmm ok, wait i made the code for you =)

    Plugin Author badbreze


    ok made this for you, copy the file in plugin directory, edit the variable value of $image_url with the url of the image you want to place in tweets with no images and save, next activate the plugin from wordpress backend =)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add featured image to all tweets’ is closed to new replies.