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

Prevent unsupported images to be used in the twitter image tag #21260

Conversation

pls78
Copy link
Member

@pls78 pls78 commented Mar 21, 2024

Context

  • We want to prevent unsupported image formats to be used for the twitter:image meta tag.

Summary

This PR can be summarized in the following changelog entry:

  • Prevents image formats other than JPG, GIF, PNG and WEBP to be used for the twitter:image meta tag.
  • [wordpress-seo other] Deprecates unused method is_image_url_valid.

Relevant technical choices:

  • N/A

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Create a new post
  • Set a featured image of an unsupported format (e.g. TIFF; use this site to convert an image to an unsupported format)
  • Visit the post in the frontend
    • verify no twitter:image nor open-graph:image meta tag is present in the page head
  • Edit the post and set a featured image of a supported type
    Visit the post in the frontend
    • verify the open-graph:image meta tag is present in the page head together with the image size information
  • Edit the post again
  • remove the post featured image
  • in the Social tab of the metaboxe specify a twitter image of a supported type
    Visit the post in the frontend
  • verify the twitter:image meta tag is present in the page head

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes #21209

@coveralls
Copy link

coveralls commented Mar 21, 2024

Pull Request Test Coverage Report for Build 64f0ac031eb6fd56159e562dc25ab55d2fe6541b

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 7 (42.86%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 54.321%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/values/twitter/images.php 0 4 0.0%
Totals Coverage Status
Change from base Build e4b23415dd2e66b1e5482f71f63d07bf47f19510: 0.5%
Covered Lines: 29605
Relevant Lines: 54550

💛 - Coveralls

@pls78 pls78 added the changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog label Mar 22, 2024
@pls78 pls78 force-pushed the prevent-unsupported-images-to-be-used-in-the-twitter-image-tag branch from 1a9fd3a to 2394f62 Compare March 22, 2024 10:27
@pls78 pls78 marked this pull request as ready for review March 22, 2024 10:30
Copy link
Member

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR 🏗️

src/generators/twitter-image-generator.php Outdated Show resolved Hide resolved
src/helpers/open-graph/image-helper.php Outdated Show resolved Hide resolved
src/helpers/open-graph/image-helper.php Outdated Show resolved Hide resolved
src/values/twitter/images.php Outdated Show resolved Hide resolved
tests/Unit/Helpers/Twitter/Image_Helper_Test.php Outdated Show resolved Hide resolved
tests/Unit/Helpers/Twitter/Image_Helper_Test.php Outdated Show resolved Hide resolved
src/helpers/twitter/image-helper.php Show resolved Hide resolved
Copy link
Member

@igorschoester igorschoester left a comment

Choose a reason for hiding this comment

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

CR && AT ✅

@igorschoester igorschoester added this to the 22.5 milestone Mar 28, 2024
@igorschoester igorschoester merged commit 1d938f8 into trunk Mar 28, 2024
23 checks passed
@igorschoester igorschoester deleted the prevent-unsupported-images-to-be-used-in-the-twitter-image-tag branch March 28, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent unsupported images to be used in the twitter:image tag
3 participants