Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant Search: add image alt text from API #22295

Merged
merged 5 commits into from
Jan 28, 2022

Conversation

bluefuton
Copy link
Contributor

@bluefuton bluefuton commented Jan 11, 2022

Fixes #19273.

Changes proposed in this Pull Request:

The Instant Search API now provides image.alt_text as a field we can request.

This PR adds the new field and switches to use it for alt text in the expanded and product result formats.

I've also reduced the fields fetched for the minimal result format (image fields are not needed).

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  1. On a site with Jetpack Instant Search enabled, create a post with an image.
  2. Set alt text for the image and ensure that the alt text appears on images in search results too (/?s=).

Screen Shot 2022-01-11 at 15 57 40

@bluefuton bluefuton self-assigned this Jan 11, 2022
@bluefuton bluefuton requested a review from a team as a code owner January 11, 2022 03:26
@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Jan 11, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 11, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: February 1, 2022.
  • Scheduled code freeze: January 24, 2022.

@bluefuton bluefuton force-pushed the add/instant-search-alt-text-where-available branch from 677c0be to cb9be12 Compare January 11, 2022 20:55
@github-actions github-actions bot added the [Package] Search Contains core Search functionality for Jetpack and Search plugins label Jan 11, 2022
@@ -77,7 +77,7 @@ export default function SearchResultExpanded( props ) {
<div className="jetpack-instant-search__search-result-expanded__image-container">
{ firstImage ? (
<PhotonImage
alt={ fields[ 'title.default' ] }
alt={ fields[ 'image.alt_text' ] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about keeping title.default as a fallback here, but it's complicated by the fact that alt="" is valid alt text.

Feels best to rely on the alt text from the API in all cases.

Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests well and looks good to me 👍
Some checks are failing, and the errors don't seem relevant to the PR - probably just need to rebase and have the checks re-run and see.

@bluefuton bluefuton force-pushed the add/instant-search-alt-text-where-available branch from ea47400 to 26f082b Compare January 13, 2022 01:23
@bluefuton
Copy link
Contributor Author

The only required check failing is 'Linting / Changelogger validity (pull_request)':

Screen Shot 2022-01-13 at 14 53 15

@Automattic/jetpack-crew can you advise whether we need to use fixup-project-versions here?

@anomiex
Copy link
Contributor

anomiex commented Jan 13, 2022

@Automattic/jetpack-crew can you advise whether we need to use fixup-project-versions here?

Well, you don't need to, you could do the version bumps manually. 😀 But fixup-project-versions saves the trouble of figuring out all the details.

P.S. if you're on a Mac and that command is really slow, you might see p7H4VZ-3gs-p2 (or https://apple.stackexchange.com/questions/338415/php-incredibly-slow-since-upgrading-macos-to-10-14-mojave)

@bluefuton
Copy link
Contributor Author

Well, you don't need to, you could do the version bumps manually. 😀 But fixup-project-versions saves the trouble of figuring out all the details.

Thanks @anomiex! Do we need to do this on every search PR in the future?

@bluefuton bluefuton force-pushed the add/instant-search-alt-text-where-available branch from a462b58 to 177ec23 Compare January 13, 2022 22:39
@anomiex
Copy link
Contributor

anomiex commented Jan 14, 2022

Thanks @anomiex! Do we need to do this on every search PR in the future?

I usually run it on my PRs that touch any project, just before pushing. It doesn't take that long and it'll safely do nothing if nothing is needed.

In general for a composer package it's only needed if you're doing the first "minor" or "major" PR since the last time the package was released (which will generally be weekly, since packages used by Jetpack get released as part of the weekly Jetpack release for Atomic), unless the package is configured with a version number constant.

@bluefuton bluefuton requested a review from kangzj January 16, 2022 22:32
@@ -0,0 +1,5 @@
Significance: patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think keeping projects/plugins/jetpack/changelog/add-instant-search-alt-text-where-available is sufficient enough?

kangzj
kangzj previously approved these changes Jan 17, 2022
Copy link
Contributor

@kangzj kangzj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! It looks good and works well 👍

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this is going to need a rebase now. :(

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Team Review labels Jan 24, 2022
@bluefuton bluefuton force-pushed the add/instant-search-alt-text-where-available branch from 177ec23 to 9118cc8 Compare January 26, 2022 02:12
@bluefuton bluefuton added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 26, 2022
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jan 28, 2022
@jeherve jeherve added this to the jetpack/10.7 milestone Jan 28, 2022
@jeherve jeherve merged commit 5d06380 into master Jan 28, 2022
@jeherve jeherve deleted the add/instant-search-alt-text-where-available branch January 28, 2022 17:01
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search [Package] Search Contains core Search functionality for Jetpack and Search plugins [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instant Search: use correct image alt text
5 participants