Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/200754

Change subject: Use images rather than background-image for page images in 
collection
......................................................................

Use images rather than background-image for page images in collection

These are more robot friendly thus SEO/social friendly

Bug: T91696
Change-Id: Id7feacd8c1224ef02b4aa9df37e6706a5d7dad73
---
M includes/views/Image.php
M resources/ext.gather.styles/collections.less
2 files changed, 20 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather 
refs/changes/54/200754/1

diff --git a/includes/views/Image.php b/includes/views/Image.php
index b8123fc..476ca97 100644
--- a/includes/views/Image.php
+++ b/includes/views/Image.php
@@ -33,10 +33,9 @@
 
        /**
         * @param integer $size the width of the thumbnail
-        * @param boolean $useBackgroundImage Whether the thumbnail should have 
a background image
         * @return string
         */
-       private function getPageImageHtml( $size = 750, $useBackgroundImage = 
false ) {
+       private function getPageImageHtml( $size = 750 ) {
                $imageHtml = '';
                if ( $this->item->hasImage() ) {
                        $file = $this->item->getFile();
@@ -46,19 +45,17 @@
                                $className .= $thumb->getWidth() > 
$thumb->getHeight()
                                        ? 'list-thumb-y'
                                        : 'list-thumb-x';
+                               $imgUrl = wfExpandUrl( $thumb->getUrl(), 
PROTO_CURRENT );
                                $props = array(
-                                       'class' => $className,
+                                       'src' => $imgUrl,
+                                       'alt' => $file->getDescription(),
                                );
 
-                               $imgUrl = wfExpandUrl( $thumb->getUrl(), 
PROTO_CURRENT );
-                               if ( $useBackgroundImage ) {
-                                       $props['style'] = 'background-image: 
url("' . wfExpandUrl( $imgUrl, PROTO_CURRENT ) . '")';
-                                       $text = '';
-                               } else {
-                                       $props['src'] = $imgUrl;
-                                       $text = $this->title->getText();
-                               }
-                               $imageHtml = Html::element( $useBackgroundImage 
? 'div' : 'img', $props, $text );
+                               $imageHtml = Html::openElement( 'div', array(
+                                               'class' => $className,
+                                       ) ) .
+                                       Html::element( 'img', $props ) .
+                                       Html::closeElement( 'div' );
                        }
                }
                return $imageHtml;
diff --git a/resources/ext.gather.styles/collections.less 
b/resources/ext.gather.styles/collections.less
index 849a0c2..7232b51 100644
--- a/resources/ext.gather.styles/collections.less
+++ b/resources/ext.gather.styles/collections.less
@@ -99,8 +99,18 @@
 
                .list-thumb {
                        height: 300px;
+                       position: relative;
                        margin: 0 -@collectionItemPadding;
-                       background-size: cover;
+                       overflow: hidden;
+
+                       img {
+                               position: absolute;
+                               left: 50%;
+                               top: 50%;
+                               // Optimise for top right of photo (if person 
head is likely to be somewhere up there)
+                               -webkit-transform: translateY(-25%) 
translateX(-50%);
+                               transform: translateY(-25%) translateX(-50%);
+                       }
                }
 
                .collection-item-title {

-- 
To view, visit https://gerrit.wikimedia.org/r/200754
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7feacd8c1224ef02b4aa9df37e6706a5d7dad73
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to