Skip to content

Deprecate Jetpack_PostImages in favor of Post_Media\Images#47376

Open
jeherve wants to merge 3 commits intotrunkfrom
deprecate-postimages-class
Open

Deprecate Jetpack_PostImages in favor of Post_Media\Images#47376
jeherve wants to merge 3 commits intotrunkfrom
deprecate-postimages-class

Conversation

@jeherve
Copy link
Member

@jeherve jeherve commented Feb 27, 2026

Fixes CM-550

Proposed changes:

Following up on #47208 (which moved Jetpack_Twitter_Cards to the post-media package), this PR applies the same deprecation pattern to Jetpack_PostImages:

  • Mark all public methods in Jetpack_PostImages as deprecated via @deprecated docblocks, pointing to the equivalent method in Automattic\Jetpack\Post_Media\Images.
  • Add _deprecated_function() runtime notices for most methods. Three heavily-used methods (from_html, fit_image_url, get_image) keep the @deprecated docblock for IDE visibility but omit the runtime notice to avoid noisy warnings in production.
  • Each deprecated method delegates to the matching Images:: method in the post-media package.
  • Remove the private get_images_from_block_attributes() helper (dead code now that from_blocks() delegates entirely).
  • Delete Jetpack_PostImages_Test.php — equivalent test coverage already exists in the package's ImagesTest.php.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

N/A — straightforward deprecation following established pattern from #47208.

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

No.

Testing instructions:

  • Verify that calling any Jetpack_PostImages:: method still returns the same results as before (the methods delegate to Images::).
  • For methods with runtime deprecation notices (e.g., from_slideshow, from_gallery, from_thumbnail, etc.), confirm a _deprecated_function notice is triggered.
  • For from_html, fit_image_url, and get_image, confirm no runtime deprecation notice is triggered, but IDEs show the method as deprecated.
  • Confirm that existing features relying on Jetpack_PostImages (Related Posts, Open Graph tags, etc.) continue to work without regressions.

Changelog

  • Generate changelog entries for this PR (using AI).

All methods in the Jetpack_PostImages class are now thin wrappers
that emit a deprecation notice and delegate to the equivalent method
in Automattic\Jetpack\Post_Media\Images, following the same pattern
used for Jetpack_Twitter_Cards in #47208.

The old test file is removed since the post-media package already
has equivalent coverage in ImagesTest.php.
Copilot AI review requested due to automatic review settings February 27, 2026 09:27
@jeherve jeherve added the [Status] Needs Review This PR is ready for review. label Feb 27, 2026
@jeherve jeherve self-assigned this Feb 27, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the deprecate-postimages-class branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack deprecate-postimages-class

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Feb 27, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2026

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.
  • ✅ Add a "[Status]" label (In Progress, Needs 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 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: March 3, 2026
    • Code freeze: March 3, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR deprecates the Jetpack_PostImages class in favor of the Automattic\Jetpack\Post_Media\Images class from the post-media package. This follows the same deprecation pattern established in PR #47208 for Jetpack_Twitter_Cards. All public methods are marked as deprecated with @deprecated docblocks pointing to their equivalents in the new Images class, and most include _deprecated_function() runtime notices. Three heavily-used methods (from_html, fit_image_url, and get_image) omit runtime notices to avoid noisy warnings in production but retain IDE-visible deprecation markers.

Changes:

  • Deprecated all 15 public methods in Jetpack_PostImages class with delegation to Automattic\Jetpack\Post_Media\Images
  • Added runtime deprecation notices to 12 methods; 3 heavily-used methods retain only docblock deprecation
  • Removed dead code (private get_images_from_block_attributes method) and test file with equivalent coverage in the package

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
projects/plugins/jetpack/class.jetpack-post-images.php Converted to thin deprecation wrapper: added @deprecated docblocks, _deprecated_function() calls, and delegation to Images class; removed unused imports and private helper method
projects/plugins/jetpack/tests/php/media/Jetpack_PostImages_Test.php Deleted test file since equivalent coverage exists in package's ImagesTest.php
projects/plugins/jetpack/changelog/deprecate-postimages-class Added changelog entry documenting the deprecation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jp-launch-control
Copy link

jp-launch-control bot commented Feb 27, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/class.jetpack-post-images.php 0/0 (—%) 39.60% -217 💚

Full summary · PHP report · JS report

The PhanTypeMismatchDefault issue no longer applies after the class
was converted to a thin deprecation wrapper.
Copilot AI review requested due to automatic review settings February 27, 2026 12:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeherve jeherve added [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Post Media [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants