Last modified: 2011-05-13 12:59:55 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30692, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28692 - Allow "image" contents to be deliverable by API
Allow "image" contents to be deliverable by API
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Roan Kattouw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-25 11:43 UTC by Brett Zamir
Modified: 2011-05-13 12:59 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Brett Zamir 2011-04-25 11:43:14 UTC
While server-side applications may be able to grab image contents (e.g., for an SVG file) by directly visiting the image URL they obtain from a prior API query, for JSONP in particular, it would be great if image contents could be exposed to be returned as content via the API (called maybe "image" or "filecontent" or whatever).

For example:

/w/api.php?action=query&titles=File:Example.svg&prop=imageinfo&iiprop=image&format=json

might return something like:

..."imageinfo":  {"image":  {"*": "<svg>....</svg>"}}

Thanks!
Comment 1 Roan Kattouw 2011-04-25 11:49:27 UTC
While SVGs are text, most other image formats, such as PNG, are binary, so we'd have to return e.g. a base64-encoded image.

Specifically if we return base64, this could be useful for constructing data URLs in JavaScript, allowing a caller to fetch multiple images with one request.
Comment 2 Brion Vibber 2011-04-25 17:52:42 UTC
Keep in mind that some files will be hundreds of megabytes or more such as videos -- embedding raw file contents into a structured-text API return won't scale as a general solution.

My recommendation is implementation of cross-origin request control to simply allow JS code running in other contexts to access the public image file data through XMLHTTPRequest -- bug 25886 covers this for the styles and whatnot on bits.wikimedia.org but it doesn't seem to have gotten filed.

Has been previously discussed as in this thread: http://www.gossamer-threads.com/lists/wiki/wikitech/220659

but as far as I know not implemented -- I've gone ahead and filed as bug 28700.

In the meantime, if you need this for your own site, for code running on the main wiki's domain, you can enable ApiSvgProxy extension. This returns raw XML data for SVGs only; it won't work over JSONP but does give you an XHR-friendly interface on your wiki's main domain.
Comment 3 Brett Zamir 2011-04-26 02:01:41 UTC
Using CORS would be absolutely wonderful, especially if as I just mentioned in bug 28700  , the API itself could be exposed to it.

However, as pointed out by Roan Kattouw, it still could be useful as per Comment 1 to reduce the number of HTTP requests. Might this request be implemented only for images and SVG, but not videos, or some other non-general solution?

(I'm not in need of this bug anymore---assuming CORS is made available for the API itself--but I'm just stating I think it could be useful.)

Thanks...
Comment 4 Bryan Tong Minh 2011-04-26 08:03:57 UTC
There is a maximum result size configuration variable for the API, we can use that as a limit to the files that can be served. (sum of file size * base64 magic factor < $wgAPIMaxResultSize)
Comment 5 Roan Kattouw 2011-04-26 15:40:49 UTC
(In reply to comment #4)
> There is a maximum result size configuration variable for the API, we can use
> that as a limit to the files that can be served. (sum of file size * base64
> magic factor < $wgAPIMaxResultSize)
IE8 has a maximum data URL length, so the ResourceLoader component that does data URL embedding will skip images larger than 24K (the data URL length limit is 32K). That could be a sane limit.
Comment 6 Brion Vibber 2011-05-13 12:59:55 UTC
Resolving as INVALID; raw binary files are not sensible to deliver through the API. Use a consistent method for general data fetches.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links