https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113404
Revision: 113404
Author: jeroendedauw
Date: 2012-03-08 21:18:48 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
use simler code thumbs
Modified Paths:
--------------
trunk/extensions/EducationProgram/includes/EPOAPager.php
Modified: trunk/extensions/EducationProgram/includes/EPOAPager.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOAPager.php 2012-03-08
20:56:26 UTC (rev 113403)
+++ trunk/extensions/EducationProgram/includes/EPOAPager.php 2012-03-08
21:18:48 UTC (rev 113404)
@@ -75,35 +75,23 @@
protected function getFormattedValue( $name, $value ) {
switch ( $name ) {
case 'photo':
- $title = Title::newFromText( $value, NS_FILE );
+ $value = explode( ':', $value, 2 );
+ $value = array_pop( $value );
+
+ $file = wfFindFile( $value );
$value = '';
- if ( is_object( $title ) ) {
- $api = new ApiMain( new FauxRequest(
array(
- 'action' => 'query',
- 'format' => 'json',
- 'prop' => 'imageinfo',
- 'iiprop' => 'url',
- 'titles' =>
$title->getFullText(),
- 'iiurlwidth' => 200
- ), true ), true );
+ if ( $file !== false ) {
+ $thumb = $file->transform( array(
'width' => 200 ) );
- $api->execute();
- $result = $api->getResultData();
-
- if ( array_key_exists( 'query', $result
) && array_key_exists( 'pages', $result['query'] ) ) {
- foreach (
$result['query']['pages'] as $page ) {
- foreach (
$page['imageinfo'] as $imageInfo ) {
- $value =
Html::element(
- 'img',
- array(
-
'src' => $imageInfo['thumburl'],
-
'width' => '200px',
- )
- );
- break;
- }
- }
+ if ( $thumb && !$thumb->isError() ) {
+ $value = Html::element(
+ 'img',
+ array(
+ 'src' =>
$thumb->getURL(),
+ 'width' =>
'200px',
+ )
+ );
}
}
break;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
