Skip to content

Tiled Gallery: add jetpack_skip_photon_domain filter to keep origin image URLs#50422

Draft
enejb wants to merge 1 commit into
trunkfrom
add/tiled-gallery-skip-photon-filter
Draft

Tiled Gallery: add jetpack_skip_photon_domain filter to keep origin image URLs#50422
enejb wants to merge 1 commit into
trunkfrom
add/tiled-gallery-skip-photon-filter

Conversation

@enejb

@enejb enejb commented Jul 10, 2026

Copy link
Copy Markdown
Member

Proposed changes

The Tiled Gallery always rewrites its image URLs onto the Photon domain (i0.wp.com), because the tiled layout needs images fetched at exact w/h/crop dimensions and Photon is the on-demand resizer that can produce them. On platforms that already have a Photon-equivalent image service built in (notably WordPress VIP), the origin host understands the same ?w=&h=&crop=&resize= query args, so routing through i0.wp.com is redundant/undesirable.

This adds a new opt-in filter, jetpack_skip_photon_domain (boolean, default false). When it returns true, tiled galleries keep the origin image domain and simply append the same resizing query args, instead of sending URLs through Photon.

Reading guide — the change touches every path that builds tiled-gallery image URLs:

  • Classic renderermodules/tiled-gallery/tiled-gallery/tiled-gallery-item.php: the img_src build now branches on the filter. Default = Image_CDN_Core::cdn_url() (Photon); opted-out = add_query_arg( $img_args, $orig_file ) (origin + same args). The filter is documented here (canonical docblock).
  • Classic module wrappermodules/tiled-gallery/tiled-gallery.php: the fallback that force-runs Image_CDN::filter_the_content() when the Image CDN module is off is now skipped when opting out, so origin URLs aren't re-photonized.
  • Block server renderextensions/blocks/tiled-gallery/tiled-gallery.php: exposes the flag to the editor JS, and adds a dephotonize_url() helper so pre-existing block content with baked-in i0.wp.com URLs is rewritten back to origin (both the main src and the srcset). The Photon-only ssl arg is dropped on origin URLs.
  • Editor initial stateclass.jetpack-gutenberg.php: adds skip_photon_domain to Jetpack_Editor_Initial_State.jetpack so the block's save-time JS can read it.
  • Block save-time JSextensions/blocks/tiled-gallery/utils/index.js: new skipPhotonDomain() reader; when true, photonizedImgProps() reuses the existing photonWpcomImage() helper (which already keeps the origin host + appends args — the same behavior VIP already gets).

Deprecated block versions (deprecated/v2, v6) are intentionally left untouched — their save output must byte-match already-saved content or blocks fail validation.

Related product discussion/links

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

No.

Testing instructions

Enable the filter (e.g. a mu-plugin):

add_filter( 'jetpack_skip_photon_domain', '__return_true' );
  • Classic gallery — create a post with [gallery ids="…" type="rectangular"]. With the filter off, view source: <img src> is https://i0.wp.com/…?w=&h=. With it on: the src is the origin host with ?w=&h=&crop=1, and no i0.wp.com remains. (Note: Image_CDN_Core::cdn_url() photonizes even when the Image CDN module is off, so the "off" state shows i0.wp.com regardless of module state.)
  • Block, newly inserted — insert a Tiled Gallery block with the filter on and save; the front-end serves origin URLs + query params. The editor preview also uses origin URLs.
  • Block, pre-existing content — a block saved with i0.wp.com URLs, filter on → server render rewrites src/srcset to origin.
  • Toggle the filter off → everything returns to i0.wp.com (no change to default behavior).

Verified on a Jurassic Ninja site across all of the above.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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 add/tiled-gallery-skip-photon-filter branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/tiled-gallery-skip-photon-filter

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 [Block] Tiled Gallery [Feature] Tiled Gallery A different way to display image galleries on your site, in different organizations and shapes. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 10, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 5 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/blocks/tiled-gallery/tiled-gallery.php 23/439 (5.24%) -0.19% 15 💔
projects/plugins/jetpack/extensions/blocks/tiled-gallery/utils/index.js 4/53 (7.55%) -0.79% 5 💔
projects/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery-item.php 0/48 (0.00%) 0.00% 2 ❤️‍🩹
projects/plugins/jetpack/class.jetpack-gutenberg.php 251/541 (46.40%) -0.09% 1 ❤️‍🩹
projects/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php 0/151 (0.00%) 0.00% 1 ❤️‍🩹

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Tiled Gallery [Feature] Tiled Gallery A different way to display image galleries on your site, in different organizations and shapes. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant