Page MenuHomePhabricator

Allow large image previews by adding max image preview tag
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

We would like to optimize the way images appear in search engines, allowing for max images when available. It should apply to all skins.

Acceptance criteria

  • Add meta tag that allows large images to be shown in Google to all skins
  • Remove all traces of the WikimediaEvents max-snippet A/B test code (

https://gerrit.wikimedia.org/g/mediawiki/extensions/WikimediaEvents/+/38c977d447292535a256eb7b360ad41632797f9d/includes/PageSplitter/PageSplitterHooks.php#73)

Documentation

https://developers.google.com/search/case-studies/large-images-case-study?hl=en
https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#max-image-preview

Developer notes

Add the following code

$out->setRobotsOptions( [ 'max-image-preview' => 'standard' ] );

If all skins:
inside includes/OutputPage.php

If Vector only:
in a suitable hook e.g BeforePageDisplay.

QA Results - Prod

ACStatusDetails
1T310267#8333298

Event Timeline

Jdlrobson updated the task description. (Show Details)
Jdlrobson updated the task description. (Show Details)
LGoto set the point value for this task to 1.Sep 29 2022, 5:16 PM
NOTE: before estimation clarify in acceptance criteria 1) whether this should be for all skins or just Vector AND 2) Whether the WikimediaEvents max-snippets A/B test code can safely be removed (if retained it could clash with this in future)

@ovasileva during estimation the question was asked whether this should be all skins or just Vector (if so which Vector(s)?)

LGoto renamed this task from Allow large image previews by adding max image preview tag to [M] Allow large image previews by adding max image preview tag.Oct 4 2022, 5:31 PM
NOTE: before estimation clarify in acceptance criteria 1) whether this should be for all skins or just Vector AND 2) Whether the WikimediaEvents max-snippets A/B test code can safely be removed (if retained it could clash with this in future)

@ovasileva during estimation the question was asked whether this should be all skins or just Vector (if so which Vector(s)?)

What are the implications for implementing it across all skins? Generally, I think Vector and Vector 2022 should be included, although I have no issues with implementing it across all skins if that's easier.

Change 838739 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/core@master] Allow large image previews by adding max image preview tag

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

Change 838790 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/core@master] Allow large image previews by adding max image preview tag

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

Change 838790 abandoned by Mabualruz:

[mediawiki/core@master] Allow large image previews by adding max image preview tag

Reason:

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

Jdlrobson updated the task description. (Show Details)
Jdlrobson added a subscriber: Mabualruz.

@ovasileva does this need to be feature flagged or can it just go out everywhere (which is what Mo's patch does)?
” Study effects of large image meta tag and ensure it does not introduce any unintended limitations” implies some kind of testing.

We also have A/B test code for max-snippet - can that be removed now or was the intention that this code would replace it?
https://gerrit.wikimedia.org/g/mediawiki/extensions/WikimediaEvents/+/38c977d447292535a256eb7b360ad41632797f9d/includes/PageSplitter/PageSplitterHooks.php#73

@ovasileva does this need to be feature flagged or can it just go out everywhere (which is what Mo's patch does)?
” Study effects of large image meta tag and ensure it does not introduce any unintended limitations” implies some kind of testing.

No A/B test will be necessary in this case, this will be observational. We will look at pageviews across various wikis after the change is deployed

We also have A/B test code for max-snippet - can that be removed now or was the intention that this code would replace it?
https://gerrit.wikimedia.org/g/mediawiki/extensions/WikimediaEvents/+/38c977d447292535a256eb7b360ad41632797f9d/includes/PageSplitter/PageSplitterHooks.php#73

We can remove the A/B testing code

Change 838739 merged by jenkins-bot:

[mediawiki/core@master] Allow large image previews by adding max image preview tag

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

Great @Mabualruz could you take care of the removal of the A/B test code in WikimediaEvents to complete this task? Thank you!

Change 838739 merged by jenkins-bot:

[mediawiki/core@master] Allow large image previews by adding max image preview tag

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

FYI, this has broken a test in ArticlePlaceholder, which blocks CI for Wikibase and other extensions. I’d appreciate some assistance at T319518 – I see that this change includes a diff that seems relevant to that test failure:

diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index 55542a3f7a..6c0b7dcc71 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -233,7 +233,7 @@ public function testMetaTags() {
         $this->assertContains( '<meta name="keywords" content="first"/>', $links );
         $this->assertContains( '<meta name="keywords" content="second"/>', $links );
         $this->assertContains( '<meta property="og:title" content="Ta-duh"/>', $links );
-        $this->assertArrayNotHasKey( 'meta-robots', $links );
+        $this->assertArrayHasKey( 'meta-robots', $links );
     }

But I have no idea if this is correct or not, or why this meta name should now change.

Change 838739 merged by jenkins-bot:

[mediawiki/core@master] Allow large image previews by adding max image preview tag

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

FYI, this has broken a test in ArticlePlaceholder, which blocks CI for Wikibase and other extensions. I’d appreciate some assistance at T319518 – I see that this change includes a diff that seems relevant to that test failure:

diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php
index 55542a3f7a..6c0b7dcc71 100644
--- a/tests/phpunit/includes/OutputPageTest.php
+++ b/tests/phpunit/includes/OutputPageTest.php
@@ -233,7 +233,7 @@ public function testMetaTags() {
         $this->assertContains( '<meta name="keywords" content="first"/>', $links );
         $this->assertContains( '<meta name="keywords" content="second"/>', $links );
         $this->assertContains( '<meta property="og:title" content="Ta-duh"/>', $links );
-        $this->assertArrayNotHasKey( 'meta-robots', $links );
+        $this->assertArrayHasKey( 'meta-robots', $links );
     }

But I have no idea if this is correct or not, or why this meta name should now change.

Thanks for the fix, I added a default value [ 'max-image-preview' => 'standard' ] to robotOptions, and that effected somehow the meta-robots key, I adjusted tests to best of my knowledge to cover the new cases. If you have an idea of why this key 'meta-robots' stopped showing I am also wondering how

Change 839608 had a related patch set uploaded (by Mabualruz; author: Mabualruz):

[mediawiki/extensions/WikimediaEvents@master] Allow large image previews by adding max image preview tag

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

Change 839608 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Remove A/B test: Allow large image previews

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

LGoto assigned this task to Edtadros.

Edward please can we verify that the meta robots tag is present in article HTML and contains the max-image-preview meta information?

Edtadros subscribed.

Test Result - Prod

Status: ✅ PASS
Environment: dewiki
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

✅ AC1: Verify meta robots tag is present in article HTML and contains the max-image-preview meta information.

Screen Shot 2022-10-20 at 9.38.05 AM.png (713×798 px, 167 KB)

Jdlrobson renamed this task from [M] Allow large image previews by adding max image preview tag to Allow large image previews by adding max image preview tag.Jan 17 2023, 5:54 PM
Jdlrobson changed the point value for this task from 1 to 3.

Did this actually do anything? The linked documentation seems to imply that max-image-preview: standard is the default, so just sending that tag on every page should have no effect.

From the task description:

https://developers.google.com/search/case-studies/large-images-case-study?hl=en

That page suggests sending max-image-preview: large, which enables large image previews. Sending max-image-preview: standard does not enable large image previews.