Here's some PHP code that might be handy for retrieving thumbnails via the API. (Consider it public domain licensed.)

/**
 * Retrieve an image thumbnail from the server
 * @param $title The title of the page, e.g. 'File:Foobar.jpg'
 * @param $width The maximum width for the thumbnail
 * @param $height The maximum height for the thumbnail
 * @return array
 **/
function imagethumb ( $title, $width, $height ) {
    $title = str_replace( ' ', '_', $title );
    $thumb = array();
$x = $this->query( '?action=query&prop=imageinfo&format=php&iiprop=url|size&titles='.$title.'&iiurlwidth='.$width.'&iiurlheight='.$height );
    foreach ( $x['query']['pages'] as $ret ) {
        $thumb['url'] = $ret['imageinfo'][0]['thumburl'];
        $thumb['width'] = $ret['imageinfo'][0]['thumbwidth'];
        $thumb['height'] = $ret['imageinfo'][0]['thumbheight'];
        $thumb['originalurl'] = $ret['imageinfo'][0]['url'];
        $thumb['originalwidth'] = $ret['imageinfo'][0]['width'];
        $thumb['originalheight'] = $ret['imageinfo'][0]['height'];
    }
    return $thumb;
}

Ryan Kaldari


On 9/7/12 1:53 PM, vjkumar wrote:
I am looking for help on how to structure the second query to get the image
information. Can you help by giving an example? Thanks.



--
View this message in context: 
http://wikimedia.7.n6.nabble.com/Api-Query-for-thumbnail-images-title-etc-in-a-category-tp4984759p4984849.html
Sent from the WikiMedia Commons mailing list archive at Nabble.com.

_______________________________________________
Commons-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/commons-l


_______________________________________________
Commons-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/commons-l

Reply via email to