Index: trunk/extensions/EducationProgram/includes/EPOAPager.php |
— | — | @@ -75,35 +75,23 @@ |
76 | 76 | protected function getFormattedValue( $name, $value ) { |
77 | 77 | switch ( $name ) { |
78 | 78 | case 'photo': |
79 | | - $title = Title::newFromText( $value, NS_FILE ); |
| 79 | + $value = explode( ':', $value, 2 ); |
| 80 | + $value = array_pop( $value ); |
| 81 | + |
| 82 | + $file = wfFindFile( $value ); |
80 | 83 | $value = ''; |
81 | 84 | |
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 ) ); |
91 | 87 | |
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 | + ); |
108 | 96 | } |
109 | 97 | } |
110 | 98 | break; |