MW gurus,
I am working on an API module to an extension and would like to create
thumbnails programmatically for some images (if they don't already have them.)
The includes/filerepo/File.php file contains a createThumb() method, which
looks like it's what I want. From the comment block directly above the
aforementioned method:
/**
* Create a thumbnail of the image having the specified width/height.
* The thumbnail will not be created if the width is larger than the
* image's width. Let the browser do the scaling in this case.
* The thumbnail is stored on disk and is only computed if the thumbnail
* file does not exist OR if it is older than the image.
* Returns the URL.
*
* ....
*/
However, this method always returns the url of the file itself and not the
thumb. From what I can tell it never generates the thumbnail (it's not in the
filesystem repo in any directory.) My code is:
<?php
# ...query to get a list of recently uploaded images (quite simple) ....
$result = $dbr->select();
# loop through them and get a thumbnail & url
foreach ( $result as $row ) {
$title = Title::newFromText( $row->page_title, NS_FILE );
$file = wfFindFile( $title );
if ( !$file ) {
continue;
}
$thumbnail_url = $file->createThumb( 80 ); # width in pixels
...add to the API result...
}
...return...
?>
I'm sure that my query return valid page titles/namespaces, and that the files
exist (both in the wiki and in the filesystem.) They are all local, and some
are quite large. I'd hate to have to send the entire image and make the browser
do the scaling, as the thumbnail will get reused and the resizing is only done
once.
Any ideas fellow MW gurus? What am I missing?
-Daniel Renfro
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l