Page MenuHomePhabricator

Implement Twitter Cards (<meta*> tags with content's metadata)
Closed, ResolvedPublic

Description

Suggestion received on wikitech-l from [[User:Mono]]:

"Could we add support for Twitter cards in Wikimedia projects? It wouldn't
be hard to do and would would be really nice for articles, images, videos -
everything linked from Wikimedia on Twitter could have a nice little
preview on Twitter.

The documentation is at https://dev.twitter.com/docs/cards - basically it
involves adding some meta tags around existing content server-side."


From the Twitter API documentation:

"Twitter cards make it possible for you to attach media experiences to Tweets that link to your content. Simply add a few lines of HTML to your webpages, and users who Tweet links to your content will have a "card" added to the Tweet that’s visible to all of their followers."


Design feedback would be welcome, to test something first on Wikimedia Commons for media files.


Version: unspecified
Severity: enhancement
URL: https://dev.twitter.com/docs/cards
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=25854
https://bugzilla.wikimedia.org/show_bug.cgi?id=41498
https://bugzilla.wikimedia.org/show_bug.cgi?id=62811

Details

Reference
bz43436

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:08 AM
bzimport set Reference to bz43436.

One thing that will require caution - especially with "carding" photos from commons - is including attribution if a photo is CC-BY-SA (and, well, generally respecting the license of the image).

See also bug 25854 (oEmbed) and bug 31338 (Facebook) for similar data export methods.

I can see that the Wikisources could utilise something like this for completed texts. We already have formalised headers with embedded/extractable metadata, and with transcluded works then an image copy of a djvu file at Commons (would need the ability to therefore select one image page from many in a file).

I would think that the WS community would like to be considered to participate for its structured and specific needs. [says he who isn't fully twitter competent]

[ Adding Tpt as CC for more Wikisource idea and feedback. ]

Wikimedia Commons also has structured title and description. On Wikimedia Commons it would be a nice touch to link photos to twitter handles. i.e. allow the media uploader to record their twitter handle (on their userpage) and cause their photo uploads to have 'twitter:creator' or 'twitter:creator:id' filled in correctly.

usermono wrote:

One more thing: Twitter cards need to be approved by Twitter. This isn't hard once the format is recognized, but the Foundation should probably submit the request. See https://dev.twitter.com/docs/cards for details.

I believe that the most important issue to solve before creating such API for images is that we don't have any system integrated into MediaWiki to extract metadata about an image (creator, description and license). If this issue is solve, I believe it would be very easy to add such API (oEmbed, Open Graph and Twitter cards) to MediaWiki.

(In reply to comment #7)

I believe that the most important issue to solve before creating such API for
images is that we don't have any system integrated into MediaWiki to extract
metadata about an image (creator, description and license).

That remembers me on a side note Esby (adding him as cc) wanted a better way to provide EXIF metadata.

With all these needs, I think we seriously need to improve API methods tailored to media files needs.

The workflow would be:
(1) Read EXIF metadata + standard description templates
(2) Provide a consistent set of metadata
(3) Implement stuff like oEmbed / Twitter Cards / Open Graph with this information

For the reading of description template, I believe it should not be done by parsing the wikitext but by a parser function that store these metadata into page_props table and override EXIF metadata in order to make the extension works with all templates (information, artwork, book...) and allow queries on this metadata.
This will allow, by example, to get easily all the file with CC BY-SA 3.0 license.

I see 3 important metadata:

  • the creator of the content. This can be a Commons user for things like photos or an other person for things like paintings or books. We can imagine to store in this field, if it is possible, only a link to an user page or a creator page. This will allow to get easily, by example, the twitter account set in user preferences.
  • the id of the license of the work like "CC BY-SA 3.0".
  • the description of the file.

(In reply to comment #7)

we don't have any system integrated into MediaWiki to extract
metadata about an image (creator, description and license).

Other people might not be aware of it: though it is not integrated into MediaWiki, we do have
https://commons.wikimedia.org/wiki/Commons:Machine-readable_data

Assigning this bug to Harsh Kothari, who volunteered to take this project.

There is a repo now without code. Is there any code yet? If so, please start submitting code. Otherwise I just might push some scaffolding...

I have made some code and pushing that code into repository.

(In reply to comment #12)

There is a repo now without code. Is there any code yet? If so, please start
submitting code. Otherwise I just might push some scaffolding...

The code is currently the extension bootstrap and is located at https://github.com/harshkothari410/TwitterCards.

usermono wrote:

Any progress on this?

(In reply to comment #15)

Any progress on this?

Yes, you can follow code progress at the following Git repository URL:
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/TwitterCards.git;a=summary

Current state is read some Commons image data and write the relevant OG/Twitter metadata.

If you wish to adapt the code for your own wiki, this is ready to tweak it for your own wiki content.

If you wish to see it tested on Wikimedia wikis, there is still some progress needed (for example, to get licenses, and for Wikinews/Wikisource content).

Harsh: I wonder what is missing here to close this as FIXED or WORKSFORME.
Does the TwitterCards extension basically work?
If so, this ticket should be closed and both potential deployment on WMF
servers and followup bug reports should be handled in separate tickets.

Harsh: I wonder what is missing here to close this as FIXED or WORKSFORME.
Does the TwitterCards extension basically work?
If so, this ticket should be closed and both potential deployment on WMF
servers and followup bug reports should be handled in separate tickets.

Yes. Basic work is done. We can close this ticket.

If so, this ticket should be closed and both potential deployment on WMF
servers and followup bug reports should be handled in separate tickets.

Opened [[bug:61487]] to keep track of this on the Wikimedia Commons use case.

(In reply to Harsh Kothari from comment #21)

Yes. Basic work is done. We can close this ticket.

Thanks!