r113404 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113403‎ | r113404 | r113405 >
Date:21:18, 8 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
use simler code thumbs
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPOAPager.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOAPager.php
@@ -75,35 +75,23 @@
7676 protected function getFormattedValue( $name, $value ) {
7777 switch ( $name ) {
7878 case 'photo':
79 - $title = Title::newFromText( $value, NS_FILE );
 79+ $value = explode( ':', $value, 2 );
 80+ $value = array_pop( $value );
 81+
 82+ $file = wfFindFile( $value );
8083 $value = '';
8184
82 - if ( is_object( $title ) ) {
83 - $api = new ApiMain( new FauxRequest( array(
84 - 'action' => 'query',
85 - 'format' => 'json',
86 - 'prop' => 'imageinfo',
87 - 'iiprop' => 'url',
88 - 'titles' => $title->getFullText(),
89 - 'iiurlwidth' => 200
90 - ), true ), true );
 85+ if ( $file !== false ) {
 86+ $thumb = $file->transform( array( 'width' => 200 ) );
9187
92 - $api->execute();
93 - $result = $api->getResultData();
94 -
95 - if ( array_key_exists( 'query', $result ) && array_key_exists( 'pages', $result['query'] ) ) {
96 - foreach ( $result['query']['pages'] as $page ) {
97 - foreach ( $page['imageinfo'] as $imageInfo ) {
98 - $value = Html::element(
99 - 'img',
100 - array(
101 - 'src' => $imageInfo['thumburl'],
102 - 'width' => '200px',
103 - )
104 - );
105 - break;
106 - }
107 - }
 88+ if ( $thumb && !$thumb->isError() ) {
 89+ $value = Html::element(
 90+ 'img',
 91+ array(
 92+ 'src' => $thumb->getURL(),
 93+ 'width' => '200px',
 94+ )
 95+ );
10896 }
10997 }
11098 break;

Status & tagging log