- # If we're dealing with a non-image, or a blacklisted image,
- # spit out the name and be done with it
- if( $nt->getNamespace() != NS_IMAGE
- || ( $this->mParsing && wfIsBadImage( $nt->getDBkey() ) ) ) {
- $s .=
- (($i%4==0) ? "<tr>\n" : '') .
- '<td><div class="gallerybox" style="height: 152px;">' .
- htmlspecialchars( $nt->getText() ) . '</div></td>' .
- (($i%4==3) ? "</tr>\n" : '');
- $i++;
-
- continue;
+ if( $nt->getNamespace() != NS_IMAGE ) {
+ # We're dealing with a non-image, spit out the name and be done with it.
+ $thumbhtml = '<div style="height: 152px;">' . htmlspecialchars( $nt->getText() ) . '</div>';
+ }
+ else if( $this->mParsing && wfIsBadImage( $nt->getDBkey() ) ) {
+ # The image is blacklisted, just show it as a text link.
+ $thumbhtml = '<div style="height: 152px;">'
+ . $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) ) . '</div>';
+ }
+ else if( !( $thumb = $img->getThumbnail( 120, 120 ) ) ) {
+ # Error generating thumbnail.
+ $thumbhtml = '<div style="height: 152px;">'
+ . htmlspecialchars( $img->getLastError() ) . '</div>';
+ }
+ else {
+ $vpad = floor( ( 150 - $thumb->height ) /2 ) - 2;
+ $thumbhtml = '<div class="thumb" style="padding: ' . $vpad . 'px 0;">'
+ . $sk->makeKnownLinkObj( $nt, $thumb->toHtml() ) . '</div>';