New filter to allow running Photon in wp-admin#6702
Conversation
For environments where all intermediate images are dynamically generated (e.g. WordPress.com, VIP Go), this can come in handy as we can re-use the same imagerresizing logic on both front-end and dashboard.
kraftbj
left a comment
There was a problem hiding this comment.
The is_admin bailout is original to Photon (JP 2.0) and, IIRC, in place to avoid Photon from caching images before they're used in public-facing ways.
On a typical WP install, this is fine since WP still creates intermediate sizes.
For sites that want to rely exclusively on dynamic image sizing, this filter or another solution to overriding the default is needed.
Adding the filter preserves the current experience for the majority while providing a method for the evolving minority.
LGTM
| */ | ||
| apply_filters( 'jetpack_photon_override_image_downsize', false, compact( 'image', 'attachment_id', 'size' ) ) | ||
| ) | ||
| false === apply_filters( 'jetpack_photon_admin_allow_image_downsize', false, compact( 'image', 'attachment_id', 'size' ) ) |
There was a problem hiding this comment.
Doesn't this mean that Photon URLs would then be saved in the database for each post includes images? That would make it difficult for one to move away from Photon later on, as it would require finding and replacing all Photon URLs in posts.
There was a problem hiding this comment.
I don't think so, but let me re-test checking that specifically.
There was a problem hiding this comment.
You're right.
The use case would be for a site that does not generate any intermediate sizes and would want to rely on Photon fully (VIP Go, in this case). Do you think this is acceptable, if we add a clear warning about the implications of this or the alternative is break out the logic for usage from the actual functionality. VIP Go, or other site owners, could remove the default filter on image_downsize from Photon and add their own that directly calls a new function that performs the work without checking any logic?
There was a problem hiding this comment.
I think that's fine, as long as the VIP Go knows to warn their clients about it whenever they want to stop using Photon. @mjangda What do you think?
There was a problem hiding this comment.
Go sites actually run their own mini instances of Photon served from the main site's domain (e.g. https://wpjobmanager.com/wp-content/uploads/2014/02/2014-02-27-at-22.36-1024x609.png?w=100) and we filter the Photon domain accordingly. So the URLs we'd be saving for Go sites would be their own domain. So, we're basically using the Photon code but not the public Photon service :)
Definitely makes sense to have a clear warning there though.
There was a problem hiding this comment.
Based on the update, I've marked this ready for merge for one of the Pit Crew to do the final sign-off.
* Readme: remove old release and add skeleton for 4.8. * Changelog: add #6572 * Changelog: add #6567 * Changelog: add #6542 * Changelog: add #6527 * Changelog: add #6508 * Changelog: add #6478 * Changelog: add #6477 * Changelog: add #6249 * Update stable version and remove old version from readme. * Changelog: add 4.7.1 to changelog. * Readme: add new contributor. * Sync: update docblock @SInCE version. Related: #6053 * Changelog: add release post. * changelog: add #6053 * Changelog: add #6413 * Changelog: add #6482 * Changelog: add #6584 * Changelog add #6603 * Changelog: add #6606 * Changelog: add #6611 * Changelog: add #6635 * Changelog: add #6639 * Changelog: add #6684 * Changelog: add #6710 * Changelog: add #6711 * Changelog: add #5461 * Testing list: update Settings UI feedback prompt. Props @MichaelArestad * Changelog: add #6789 * Changelog: add #6778 * Changelog: add #6777 * Changelog: add #6775 * Changelog: add #6755 * Changelog: add #6731 * Changelog: add #6721 * Changelog: add #6705 * Changelog: add #6702 * Changelog: add #6671 * Changelog: add #6637 * Changelog: add #6582 * Changelog: add #6566 * Changelog: add #6555 * Changelog: add #6529 * Changelog: add #6344 * Changelog: add #5763 * Changelog: add #5503 * Changelog: update #6637 changelog. @see 40e115c#commitcomment-21523982 * Changelog: add #6699 * Changelog: add #6632 * Changelog: add #6769 * Changelog: add #6707 * Changelog: add #6590
Proposed new filter is called:
jetpack_photon_admin_allow_image_downsize.This will allow Photon's
image_downsizecallback to run when viewing the Dashboard. For environments where all intermediate images are dynamically generated (e.g. WordPress.com, VIP Go), this can come in handy as we can re-use the same imagerresizing logic on both front-end and dashboard. Currently Photon just bails early when in anis_admin()context.Usage:
/cc @kraftbj