WordPress.org

Ready to get started?Download WordPress

Forums

Twitter embeds not working in 3.4 (27 posts)

  1. justted
    Member
    Posted 1 year ago #

    Hello,

    I just updated to 3.4 and I cannot get twitter embeds to work. I went to the twenty-eleven theme and disabled all plugins, thinking there was a conflict, but I still get just the URL displayed on the post. I have emptied the browser cache and tried a different browser just in case (Chrome and Safari)

    I've tried it with both the http and https, for example:

    https://twitter.com/BarackObama/status/213085892846424067

    and

    http://twitter.com/BarackObama/status/213085892846424067

    Any clue what could be going on here?

    Thanks

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    A bit of a guess here, but embeds never seem to work for me.

    I find that when I go to edit the post (whether a twitter or a youtube embed), I switch over to html view and the URL has been auto wrapped by a link, so it looks like:

    <a href="https://twitter.com/BarackObama/status/213085892846424067">https://twitter.com/BarackObama/status/213085892846424067</a>

    And it just displays as a link. If, while in html mode, I manually delete the wrapper so it's just my original URL again, and publish, my embeds work fine.\

    Give that a try and see if it helps perhaps?

  3. FRANTIC
    Member
    Posted 1 year ago #

    ^ that should do the trick.

    My problem with the new Twitter embeds in WP 3.4 is that they have a set width, which conflicts with the dimensions of the content area on my site. So, all embedded tweets get cut off by 20 pixels or so.

    Anyone else come across this?

  4. I've just pasted the two URLs you've put there into my test install. Both works fine for me. I did have to paste them in via the HTML editor because Windows included all the HTML. But it worked.

    I'm on 3.4 and I don't have any plugins and I'm using the Twenty Eleven theme.

    Try wrapping them in [embed] like so, see if that helps.

    [embed]https://twitter.com/BarackObama/status/213085892846424067[/embed]
    
    [embed]http://twitter.com/BarackObama/status/213085892846424067[/embed]
  5. FRANTIC
    Member
    Posted 1 year ago #

    @Jan: any idea on the width issue?

  6. Many! Or so I think. ;)

    Is there a link that can be shared so I can see by example the width problem?

  7. FRANTIC
    Member
    Posted 1 year ago #

  8. FRANTIC
    Member
    Posted 1 year ago #

    Looks like the width is set to 550px inline on the tweet wrapper (id=twitter-widget-0 and class=twitter-tweet-rendered).

  9. Yep, and after looking I found where it can be filtered too. Otto wrote about it in a comment.

    http://ottopress.com/2011/twitter-adds-oembed-adding-it-to-wordpress-with-a-snippet/comment-page-1/#comment-10327

    This works.

    http://pastebin.com/Gz1Kaz8J

    add_filter('oembed_result','twitter_no_width',10,3);
    function twitter_no_width($html, $url, $args) {
            if (false !== strpos($url, 'twitter.com')) {
                    $html = str_replace('width="550"','width="200"',$html);
            }
            return $html;
    }

    Add this to your theme's functions.php file (make a backup copy first) and play with that width="200" value.

    The oembed_result happens once, so edit and save your post to update the oembed cache if you make changes to the width.

    Edit: Your .hentry-middle is 460px, so try around that value to make it fit.

  10. FRANTIC
    Member
    Posted 1 year ago #

    Awesome! Worked like a charm.

    Thanks for the help, Jan.

  11. justted
    Member
    Posted 1 year ago #

    Thanks for all the help - I am finding though that sometimes the embeds work, sometimes they don't.

    Putting an [embed] tag in front just turns the text into a hyperlink.

    Is anyone else having this problem?

    I've turned off all plugins and gone to the stock theme and it's still happening - some posts the embed takes some it doesn't. Is this a Twitter api problem?

  12. I think it's actually your browser. I never have the problem on Chrome, I always have it on Safari.

  13. justted
    Member
    Posted 1 year ago #

    I just tried it with Chrome, and the problem persists.

    I can actually come back after a few hours, put up a post with a twitter link, that does embed correctly, and then try again a few hours later and it does not, with no changes to the blog settings.

    Pasting the embed code from twitter.com works fine, so I can use that in the meantime.

    Any other ideas as to what's going on?

    I'm on Dreamhost with Cloudflare by the way. I put things in developer mode to turn off caching to see if that made a difference, it didn't.

  14. padraigbeirne
    Member
    Posted 1 year ago #

    Hi justted,

    Had the exact same problem and this resolved it for me...

    On your admin dashboard go to Settings > Media

    Under the 'Embeds' title make sure Auto-Embeds is ticked. Pasting twitter urls should now work just like pasting youtube, vimeo and flickr urls. More info here - http://codex.wordpress.org/Embeds

    Hope this works for you! :-)

  15. sanerdesign
    Member
    Posted 1 year ago #

    If anyone is interested in a responsive option for twitter embeds until they come up with an answer I came up with an option here http://sanerdesign.com/2012/07/twitter-embed-width-issue-wordpress-fix/

    It's just a small bit of js that waits 100ms and then removes the inline style that Twitter adds

    Hope it helps someone

  16. cspowers
    Member
    Posted 1 year ago #

    For what it's worth. I was having the same problem. No matter what I did, pasting a tweet into a new post would not get formatted. Out of desperation I went in to Settings -> Media. The auto embed box was checked.

    But I unchecked the box, saved my settings, checked the box again, saved my settings again. And it has worked for me ever since.

    FWIW

  17. cspowers
    Member
    Posted 1 year ago #

    the other thing I have noticed is that if the link is wrapped with anything at all, the embed code will not be generated.

    For example, I pasted a twitter link into a new post and published it. Displayed just fine. Then I edited the post again and right aligned the link because I wanted to put it on the right side like an image and wrap text around it so it would appear like a callout. Didn't work. Just the link just displayed as left aligned text paragraph.

    Given that you can't control the alignment, wrapping or size with the default embed function, I'm going to use the twitter generated html code instead to give me better control over the formatting

  18. Shyzer
    Member
    Posted 1 year ago #

    cspowers, just wanted to jump in here and say thanks. Ticking that box fixed my problem as well.

  19. Paul Cole
    Member
    Posted 1 year ago #

    Hi all

    I also had this issue when working on a really long post full of embedded tweets to demonstrate live twitter coverage of a meeting (not yet published).

    Anyway, I got the occasional issue with the embedded tweets vanishing and just the URL remaining. I kept restoring previous versions and got really frustrated.

    It all seemed to happen (as cspowers noted) when the formatting altered: either when I did something or when inserting an images changed the alignment without me wanting it to.

    I had almost finished the post last night and the issue had completely beaten me. I'd checked, unchecked and rechecked the box to enable embedding, restored almost every previous version and even copy and pasted the entire post into a new post.

    Nothing. Fail.

    Woke up this morning with new energy and tried pasting the entire post into a new post as plain text. YES! It worked, although I'd have to go through the entire thing and correct all the paragraph spacing, which may cause me problems again.

    So, I tried simply cutting and pasting the first tweet back into the post as plain text, just to see if it would work and I could then do the rest of the tweets.

    Bingo! When I previewed it, all the embedded tweets had been restored!

    I've saved it and left it alone for now. It's a great feature, but I think there are still some bugs to iron out.

    Hopefully this will continue to work for me and may work for some of you.

    cheers

  20. NewYorkerAtHeart
    Member
    Posted 1 year ago #

    So nice to see I wasn't the only one struggling with this. I was able to get it to work using @cspowers media settings tip. But then it happened again, so I switched from safari to google chrome and tried the media settings tip and it worked. So perhaps you need to jump back and forth??? But then I tried viewing the embedded tweets on my iPhone and they didn't even come close to fitting properly (as they did on the blog post) and they didn't embed all the links either. Yuck! I'm going to just manually put in the tweets and style them for now.....unless twitter/wordpress.org fixes this!

  21. notpoppy
    Member
    Posted 1 year ago #

    I'm having the same problem as Paul Cole @paul-cole but the solution he suggested isn't working for me:

    If anyone can help, please let me know here:

    http://wordpress.org/support/topic/twitter-oembed-tweets-not-displaying-maximum-number-per-post-1?replies=1#post-3312362

  22. Vedran
    Member
    Posted 1 year ago #

    In my case there were two identical posts, both with just direct twitter links (albeit different). One post worked, the other one didn't.

    I got the other one to work by simply switching to the Visual editor and then back to HTML. Right after saving everything started working just fine.

  23. notpoppy
    Member
    Posted 1 year ago #

    Thanks Vedran, unfortunately I just tried this a few times and it made absolutely no difference for me.

  24. mhk1058
    Member
    Posted 1 year ago #

    Resorted to Twitter embed code, the link/page format option can change from an embedded tweet to a link before your eyes with nothing more than a page refresh... very odd.

  25. notpoppy
    Member
    Posted 1 year ago #

    Yep that sounds exactly the same as my problem, and using the manual Twitter embed code is the best workaround I've found so far.

  26. Victor
    Member
    Posted 1 year ago #

    I have the same issue, my embed tweet shows plain text. did anyone come out with a solution?

  27. jeremyers1
    Member
    Posted 1 year ago #

    I have the same problem... and not only that, but there is no box in Media Settings for "Auto Embeds." Did it get removed in a recent version of WP?

Topic Closed

This topic has been closed to new replies.

About this Topic