All-Nude Tweets (Hacking Extraneous Content from Twitter Embeds) – Updated

The Twitter default is for “cards” and “conversation” to display, but you can get rid of them either tweet by tweet or through a copy-paste-search-and-replace-re-copy-paste.

(I’ve developed an approach for achieving the desired effect via function, but this post is still good background!)

Intro

When you embed a tweet from its URL – for example, for this tweet from Justin Tiehen’s list of explanations for the rise of Donald Trump

https://twitter.com/jttiehen/status/735315944428310528

…it will, by the magic of oEmbed, produce the following display in your WordPress page1:

Tweet with conversation and card

Tweet with “Conversation” and “Card”

Now, a lot of the time, this is totally superduper: You’re happy to include the replied-to tweet, and the part down below, with the image of Mr. Trump there linking to the original article (in a real tweet embed, not the screenshot version of it I’ve used above), is very nifty and even useful, and the nifty formatting is also nifty: Altogether just what your nifty users want.

In some contexts, however, all of the extra stuff is just distracting – especially if you’re showing a long list of tweets or rendering a conversation.2

What follows is a hacky way to grab naked tweets instead.

Grabbing Naked Tweets

The top part of the tweet imaged above (showing a compressed “replied-to” tweet that mentions “pornography”) is “conversation.” The bottom part is “the card.”

If you’re using the oEmbed method, you can bring up the the page source and find something like the below buried in all of the code. (If you’re using Twitter’s more laborious but flexible “Embed” sub-menu, you’ll get something similar.)

The last line is a call to the Twitter Javascript file that adds all the nifty formatting. It needs to be invoked only once per page, but, in a list of 100 tweets embedded by hand, it will be listed 100 times, in 100 paragraphs that will be “un-displayed.”

Twitter also supplies users you with a relatively cumbersome way of getting rid of cards and conversation: When, instead of oEembedding from the URL (i.e., using built-in WordPress oEmbed functionality), you use the Twitter-supplied “embed” code, and you un-check the “include parent conversation” checkbox, you can get rid of the replied-to tweet. The code will look like this:

Producing a display like this:

Tweet with Card, but no Conversation

Tweet with Card, but no Conversation

The only difference between the two Twitter-supplied versions is visible in the first line: the data-conversation="none" added to the blockquote .

So, it turns out, the simple hacky way to produce a set of fancy tweets 1) without “conversation,” 2) without redundant calls to the twitter platform (slows things down a lot on a long list), and 3) in a “hard copy” form that is savable even if the user deletes the tweet or Twitter does, is

  1. Copy-paste the tweets as rendered from page source into a text editor.
  2. Use a search-and-replace to add data-conversation="none" to every blockquote (as in the example above).
  3. Search and replace (with nothing) all but one of the <p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
  4. Copy-paste the “cured” text into your HTML panel in place of what you currently have there (i.e., bunch of Twitter URLs or Embeds).

To make the Twitter Card also disappear, you include data-cards="hidden" . So…

…should display like this:

Tweet with "Conversation" and "Card" suppressed

Tweet with “Conversation” and “Card” suppressed

Summary: The Twitter default is for cards and conversation to display, but you can turn them off either tweet by tweet or through a copy-paste-search-and-replace-re-copy-paste.3

Someday…

…I’ll look further into automating this “curing” process… If somebody has done it already – let me know!

Notes:

  1. …as of this writing – Twitter may change its mind without memo-ing me personally []
  2. Multiple redundant “asynchronous” Javascript calls seem also to slow down page rendering – something to be tested at some point. []
  3. Note: You can delete the data-width=”550″ or you can adjust it to a lower value than 550. Higher values will have no effect, or, if mistyped, will break the formatting script. The Twitter embed size CAN be overriden, but you need to work from another direction. []

WordPresser
Home Page  Public Email  Twitter  Facebook  YouTube  Github   

Writing since ancient times, blogging, e-commercing, and site installing-designing-maintaining since 2001; WordPress theme and plugin configuring and developing since 2004 or so; a lifelong freelancer, not associated nor to be associated with any company, publication, party, university, church, or other institution. 

0 comments on “All-Nude Tweets (Hacking Extraneous Content from Twitter Embeds) – Updated

Commenting at CK MacLeod's

We are determined to encourage thoughtful discussion, so please be respectful to others. We also provide a set of Commenting Options - comment/commenter highlighting and ignoring, and commenter archives that you can access by clicking the commenter options button (). Go to our Commenting Guidelines page for more details, including how to report offensive and spam commenting.

    1 Pings/Trackbacks for "All-Nude Tweets (Hacking Extraneous Content from Twitter Embeds) – Updated"
    1. […] few months ago, I noted a technique for stripping Twitter embeds of extraneous conversation, involving setting the tweet attribute “data-conversation” to “none.” What […]

    Commenter Ignore Button by CK's Plug-Ins

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    Noted & Quoted

    This is a Waterloo moment for Trump, the tea party and their alliance.  They have been stopped in their tracks not only by Democratic opposition but because of a mutiny within their own ranks. Although never particularly liked or respected, it is now clear that they are no longer feared. The bankruptcy of their ideas and their incompetence have been exposed. Their momentum has been dissipated. Their rejection of political norms has itself been scorned. Our long national nightmare may finally be coming to an end.

    Comment →

    One seasoned Democrat told me that among the reasons Trump won in 2016 was that a long year of Crooked Hillary talk, about emails and Goldman Sachs and the like, had steadily demoralised and demobilised the liberal base. If sustaining fury at Trump helps keep those same voters energised, so they eventually turn out to defeat him, it’ll be worth it, he says.

    But it can’t just be in the form of world-weary, if witty, tweets. What’s needed is a coherent argument, one that explains why Trump’s repulsive behaviour matters. For Americans, that will surely centre on the state of their society. The civic realm is being degraded by Trump’s lies, vanities and insults. The national conversation is being coarsened. The basic democratic assumption, that disagreements can be resolved through discussion rather than coercion and violence, is being eroded from the very top. Note the language of Scaramucci’s outburst: “I want to fucking kill all the leakers.”

    Comment →

    [C]limate scientists have a strange kind of faith: We will find a way to forestall radical warming, they say, because we must.

    It is not easy to know how much to be reassured by that bleak certainty, and how much to wonder whether it is another form of delusion; for global warming to work as parable, of course, someone needs to survive to tell the story. The scientists know that to even meet the Paris goals, by 2050, carbon emissions from energy and industry, which are still rising, will have to fall by half each decade; emissions from land use (deforestation, cow farts, etc.) will have to zero out; and we will need to have invented technologies to extract, annually, twice as much carbon from the atmosphere as the entire planet’s plants now do. Nevertheless, by and large, the scientists have an enormous confidence in the ingenuity of humans — a confidence perhaps bolstered by their appreciation for climate change, which is, after all, a human invention, too. They point to the Apollo project, the hole in the ozone we patched in the 1980s, the passing of the fear of mutually assured destruction. Now we’ve found a way to engineer our own doomsday, and surely we will find a way to engineer our way out of it, one way or another. The planet is not used to being provoked like this, and climate systems designed to give feedback over centuries or millennia prevent us — even those who may be watching closely — from fully imagining the damage done already to the planet. But when we do truly see the world we’ve made, they say, we will also find a way to make it livable. For them, the alternative is simply unimaginable.

    Comment →
    CK's WP Plugins

    State of the Discussion

    CK MacLeod
    Ignored
    Comments this threadCommenter Archive
    + BTW, I recently upgraded some this and that on the back end of the blog, and it does seem to make comments post much faster [. . .]
    Gutenberg: The Invention of the Printing Press, the Destruction of WordPress
    CK MacLeod
    Ignored
    Comments this threadCommenter Archive

    For WordPress self-hosted people, there is already a "restore legacy editor" plugin, even though Gutenberg hasn't been installed yet as the default.

    Gutenberg: The Invention of the Printing Press, the Destruction of WordPress
    CK MacLeod
    Ignored
    Comments this threadCommenter Archive
    + I thought you were on WordPress.com, not self-hosted WordPress. I can't find any info on WordPress.com and Gutenberg or Gutenbergerish editing, so I don't know [. . .]
    Gutenberg: The Invention of the Printing Press, the Destruction of WordPress

    Extraordinary Comments

    CK's WP Plugins

    Categories

    Related