jenkins-bot has submitted this change and it was merged.
Change subject: [Card 1366] Add page image to last edited information
......................................................................
[Card 1366] Add page image to last edited information
Change-Id: Ia13b3eab2e6ed04c4cd5355aec50248715418e75
Dependency: I3e891ee65476eb72b5ffd65d9af3ac1f080d849e
---
M includes/specials/SpecialUserProfile.php
1 file changed, 20 insertions(+), 2 deletions(-)
Approvals:
Awjrichards: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specials/SpecialUserProfile.php
b/includes/specials/SpecialUserProfile.php
index 62f47e0..38f724a 100644
--- a/includes/specials/SpecialUserProfile.php
+++ b/includes/specials/SpecialUserProfile.php
@@ -1,6 +1,8 @@
<?php
class SpecialUserProfile extends MobileSpecialPage {
+ const IMAGE_WIDTH = 320;
+
protected $mode = 'beta';
protected $disableSearchAndFooter = false;
@@ -46,7 +48,7 @@
// uset MediaTransformOutput::getUrl,
unfortunately MediaTransformOutput::toHtml
// returns <img> tag with fixed height which
causes the image to be deformed when
// used with max-width
- 'src' => $file->transform( array( 'width' =>
320 ) )->getUrl(),
+ 'src' => $file->transform( array( 'width' =>
self::IMAGE_WIDTH ) )->getUrl(),
// FIXME: Add more meaningful alt text
'alt' => $title->getText(),
) ) .
@@ -90,13 +92,29 @@
$rev = $this->userInfo->getLastEdit();
if ( $rev ) {
$daysAgo = $this->getDaysAgo( new MWTimestamp(
wfTimestamp( TS_UNIX, $rev->getTimestamp() ) ) );
+ $imageHtml = '';
+ if ( defined( 'PAGE_IMAGES_INSTALLED' ) ) {
+ $title = $rev->getTitle();
+ $file = PageImages::getPageImage( $title );
+ if ( $file ) {
+ $thumb = $file->transform( array(
'width' => self::IMAGE_WIDTH ) );
+ if ( $thumb && $thumb->getUrl() ) {
+ $imageHtml = Html::element(
'img',
+ array( 'src' =>
wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT ) )
+ );
+ }
+ }
+ }
$html = Html::openElement( 'div', array( 'class' =>
'card' ) )
- . Html::openElement( 'div', array( 'class' =>
'container caption' ) )
+ . Html::openElement( 'div', array( 'class' =>
'container' ) )
+ . $imageHtml
+ . Html::openElement( 'div', array( 'class' =>
'caption' ) )
. $this->msg(
'mobile-frontend-profile-last-edit',
$rev->getTitle(),
$daysAgo
)->parse()
. '</div>'
+ . '</div>'
. '</div>';
} else {
$html = '';
--
To view, visit https://gerrit.wikimedia.org/r/93801
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia13b3eab2e6ed04c4cd5355aec50248715418e75
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits