GOOWOO-447: Implement image proxying for generated images to bypass adblockers#3248
GOOWOO-447: Implement image proxying for generated images to bypass adblockers#3248AlejandroPerezMartin wants to merge 26 commits intodevelopfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/GOOWOO-383-genai-assets #3248 +/- ##
===================================================================
- Coverage 66.3% 66.2% -0.0%
- Complexity 5267 5293 +26
===================================================================
Files 898 901 +3
Lines 27419 27624 +205
Branches 1645 1658 +13
===================================================================
+ Hits 18174 18298 +124
- Misses 9004 9075 +71
- Partials 241 251 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
asvinb
left a comment
There was a problem hiding this comment.
@AlejandroPerezMartin That's a good start. Can you kindly check my comments please? Also, if you can fix the linting issues, for both JS and PHP please. Thanks!
jjgrainger
left a comment
There was a problem hiding this comment.
Thanks @AlejandroPerezMartin overall looks good, I've left some feedback to make this a little more restrictive. Let me know if you have any questions. Thanks
Co-authored-by: Asvin Balloo <asvin.balloo@gmail.com>
…m:woocommerce/google-listings-and-ads into feature/GOOWOO-447-genai-adblocker-images
…genai-adblocker-images
…m:woocommerce/google-listings-and-ads into feature/GOOWOO-447-genai-adblocker-images
jjgrainger
left a comment
There was a problem hiding this comment.
Thanks @AlejandroPerezMartin @jamesmorrison PR looks good
QA Status: Need Remediation
|
There was a problem hiding this comment.
Pull request overview
This PR implements server-side image proxying to bypass adblockers that block AI-generated images from Google's syndication domain. When adblockers are active, they prevent the direct loading of images from googlesyndication.com, making it impossible for users to preview AI-generated content. The solution proxies these images through the WordPress site's own domain by fetching them server-side and streaming them back to the client.
Changes:
- Added a REST API endpoint
/wc/gla/ads/assets/image-proxythat accepts image URLs, fetches them server-side, and returns the binary data - Created comprehensive test coverage for the proxy endpoint including authentication, error handling, and edge cases
- Integrated the proxy utility into the frontend GenAI image picker component to transparently proxy image URLs at render time
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/API/Site/Controllers/Ads/AssetImageProxyController.php | Implements the image proxy REST controller with validation, fetching, and binary response handling |
| tests/Unit/API/Site/Controllers/Ads/AssetImageProxyControllerTest.php | Comprehensive test suite covering success, error scenarios, authentication, and security edge cases |
| src/Internal/DependencyManagement/RESTServiceProvider.php | Registers the new image proxy controller in the dependency injection container |
| js/src/utils/getProxiedImageUrl.js | Utility function to convert external image URLs to proxied URLs with nonce authentication |
| js/src/components/paid-ads/asset-group/asset-group-editor/gen-ai-image-picker/index.js | Updates the image picker to use proxied URLs for rendering while preserving original URLs in state |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
asvinb
left a comment
There was a problem hiding this comment.
@AlejandroPerezMartin That’s a good start. To address the AdBlocker issue outside of GenAIImagePicker, I suggest the following:
- Update
handleOnAddSelectedImagesinImagesSelectorto include thethumbnailproperty to images being added.MediaSelectorchecks for thethumbnailproperty first and falls back tourlonly if it’s not present. At the moment, we’re primarily providing theurlproperty. - The
thumbnailvalue should be derived usinggetGoogleAdsImageProxyUrlto ensure the image is properly proxied.
…m:woocommerce/google-listings-and-ads into feature/GOOWOO-447-genai-adblocker-images
…m:woocommerce/google-listings-and-ads into feature/GOOWOO-447-genai-adblocker-images
…genai-adblocker-images
…rce/google-listings-and-ads into feature/GOOWOO-447-genai-adblocker-images
…m:woocommerce/google-listings-and-ads into feature/GOOWOO-447-genai-adblocker-images


Changes proposed in this Pull Request:
Registers an endpoint used in the admin to render the AI generated images and bypass adblockers that are currently blocking them. It's only used to render the image previews, the selected images URLs will store the original URL upon saving the campaign.
Closes https://linear.app/a8c/issue/GOOWOO-447/generated-images-are-not-rendered-when-ad-blocker-is-active
Initial approach is to show a message to inform users that adblockers can affect the image previews from loading but I don't think users would create a campaign without knowing what images will be generated and this solution seems to work fine, tested with uBlock, PrivacyBadger and Adblock, none of them are blocking the images anymore.
Screenshots:
Detailed test instructions:
Important: You need to use a publicly accessible URL e.g. Ngrok; local URL's (e.g.
woo.test) will not work.Additional details:
Changelog entry
Prevent adblockers from blocking auto-generated images in the preview