Template:Book cover/doc

This template uses the Google Books API to retrieve and display a book cover image for a given ISBN (International Standard Book Number).

It is designed to work with the  produced by Special:BookSources. That page removes punctuation from the supplied ISBN before generating, so this template does not need to handle punctuated or other formatted ISBN numbers.

This template uses JavaScript, supplied by Widget:Book cover, to manage the connection to the Google Books API. Book cover images are retrieved asynchronously, and after the page has loaded.

Usage
Invoke with:

Parameters:
 * isbn: The ISBN for which the cover image is needed. Must be supplied. Should be a valid 10 character or 13 character ISBN.
 * style: Sets the CSS style for the generated tag. Optional. Default is float: right; margin-left: 8px; border: 1px solid #c0c0c0 (values optimized for Special:BookSources).

Parameters may also be supplied by position, in the order shown above. This template may be transcluded multiple times on a single page. ISBNs are checked for basic formatting. That is: The final character is a check digit. It must be present, but is not validated. If full validation is required, callers should validate ISBNs before transcluding this template.
 * it must be 10 or 13 characters long after removing any existing hyphen or space formatting; and
 * for 13 character ISBNs, all the characters must be digits, and it must start with 978 or 979.
 * for 10 character ISBNs, all the characters except the final one must be digits, and the final character must be either a digit or X.

Error cases
This template displays book cover images only for ISBNs that identify books for which Google Books holds a cover image. In all other cases, it does nothing.

Limitations
Book cover image URLs are retrieved locally by the browser, and only after the page has loaded. Wikitext and the MediaWiki framework therefore have no visibility of the book cover image itself, only the code that retrieves it.

If the Google Books API receives too many requests in a given amount of time, Google throttles it ("rate limiting"). This means that the number of book covers that can be retrieved by a single page before API requests are refused will have an upper limit. Additionally, Widget:Book cover times out any cover requests that could not be satisfied within five seconds.

In practice, Bogleheads:Book sources (invoked by Special:BookSources) transcludes this template once only, and cannot be reloaded by the browser sufficiently quickly to trigger Google Books API throttling.