Hey,
I'm seeing some weird behavior and can't figure out what's going on.
I have some code making a request to the API to obtain the thumb url of an image: http://dpaste.org/nuOfX/
This code is used here, and right now the first two images are full size and the third is a thumb: http://education.wmflabs.org/wiki/Special:CampusAmbassadors
No idea why it's working for some and not for others. Stranger yet, I cannot reproduce this issue locally, running the same code. This is with trunk and with instant commons on.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Thu, Mar 8, 2012 at 12:39 PM, Jeroen De Dauw jeroendedauw@gmail.com wrote:
Hey,
I'm seeing some weird behavior and can't figure out what's going on.
I have some code making a request to the API to obtain the thumb url of an image: http://dpaste.org/nuOfX/
This code is used here, and right now the first two images are full size and the third is a thumb: http://education.wmflabs.org/wiki/Special:CampusAmbassadors
No idea why it's working for some and not for others. Stranger yet, I cannot reproduce this issue locally, running the same code. This is with trunk and with instant commons on.
I don't know why this happens, but you really don't need internal API requests to get thumbnail URLs. This is much simpler:
$file = wfFindFile( 'Foobar.jpg' ); $thumb = $file->transform( array( 'width' => 200 ) ); if ( $mto && !$mto->isError() ) { $url = $mto->getURL(); } else { /* Handle error */ }
Roan
On Thu, Mar 8, 2012 at 3:51 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
I don't know why this happens, but you really don't need internal API requests to get thumbnail URLs. This is much simpler:
$file = wfFindFile( 'Foobar.jpg' ); $thumb = $file->transform( array( 'width' => 200 ) ); if ( $mto && !$mto->isError() ) { $url = $mto->getURL(); } else { /* Handle error */ }
s/$thumb/$mto/?
-Chad
On Thu, Mar 8, 2012 at 12:58 PM, Chad innocentkiller@gmail.com wrote:
On Thu, Mar 8, 2012 at 3:51 PM, Roan Kattouw roan.kattouw@gmail.com wrote:
I don't know why this happens, but you really don't need internal API requests to get thumbnail URLs. This is much simpler:
$file = wfFindFile( 'Foobar.jpg' ); $thumb = $file->transform( array( 'width' => 200 ) ); if ( $mto && !$mto->isError() ) { $url = $mto->getURL(); } else { /* Handle error */ }
s/$thumb/$mto/?
Yeah, I changed my mind about the variable name halfway through. When I say $mto I mean $thumb (or vice versa).
Roan
Hey,
$file = wfFindFile( 'Foobar.jpg' ); $thumb = $file->transform( array( 'width' => 200 ) ); if ( $mto && !$mto->isError() ) { $url = $mto->getURL(); } else { /*
Handle error */ }
I tried your code, and now all my images are "FOOBAR". It does not work!
More seriously though: I updated my code to use this indeed better way to get the thumb ( http://dpaste.org/XIr5W/ ), but the problem appears to be completely unaffected :/
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Thu, Mar 8, 2012 at 1:24 PM, Jeroen De Dauw jeroendedauw@gmail.comwrote:
Hey,
$file = wfFindFile( 'Foobar.jpg' ); $thumb = $file->transform( array( 'width' => 200 ) ); if ( $mto && !$mto->isError() ) { $url = $mto->getURL(); } else { /*
Handle error */ }
I tried your code, and now all my images are "FOOBAR". It does not work!
;)
More seriously though: I updated my code to use this indeed better way to get the thumb ( http://dpaste.org/XIr5W/ ), but the problem appears to be completely unaffected :/
I'm not sure why the width parameter doesn't seem to be taking effect in the transform.... but rather than creating your own <img> element you may wish to use $thumb->toHtml() just for consistency.
Hmm... it looks like there's a bug in thumbnailing with InstantCommons here.
at http://education.wmflabs.org/wiki/File:Kitten%27s_paw.jpg the thumbnail in the version dialog is also actually pulling in a full-size image.
Checking a direct api hit to Commons: https://commons.wikimedia.org/w/api.php?action=query&titles=File:Kitten%...
note there's a separate 'url' (the original size url) and 'thumburl' (scaled url). Don't see an obvious reason for breakage though... seems ok in my local trunk instances too.
-- brion
wikitech-l@lists.wikimedia.org