-
Notifications
You must be signed in to change notification settings - Fork 136
[Blaze] Fix campaign creation when products use a PDF file thumbnail as image #14642
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
[Blaze] Fix campaign creation when products use a PDF file thumbnail as image #14642
Conversation
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
6a98aae to
5a9d0e9
Compare
5a9d0e9 to
91fa844
Compare
AdamGrzybkowski
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with trunk to reproduce first and then confirmed the campaign creation works with this PR ✅
Any reason you haven't added a milestone?
Thanks for the review @AdamGrzybkowski, I just missed it 🙂 |
Closes WOOMOB-1348
Description
This PR fixes an issue where the app could send a PDF URL in the
main_image.urlfield when creating a campaign, andmain_image.mime_typeset toapplication/pdf.For more information on how this happens, check out the details here: pe5sF9-4CI-p2. In short, the product image is set to a thumbnail of a PDF file uploaded to the store, and the app uses the PDF URL and not the thumbnail URL, this was caused by the fact that we fetch the Media object to get its mime type, resulting in using a different URL. To fix this, this PR updates the logic to infer the MIME type when fetching image dimensions, so we no longer need to fetch the Media object. This also optimizes the campaign creation process by eliminating one API request.
To explain this more, for the test store that we'll use for reproducing the issue, the details are shown below:
Product details:
{ "id": 62, "name": "PDF Image Product", "slug": "pdf-image-product", "permalink": "https:\/\/fortunately-square.jurassic.ninja\/product\/pdf-image-product\/", "images": [ { "id": 61, "date_created": "2025-09-19T15:12:06", "date_created_gmt": "2025-09-19T15:12:06", "date_modified": "2025-09-19T15:12:06", "date_modified_gmt": "2025-09-19T15:12:06", "src": "https:\/\/fortunately-square.jurassic.ninja\/wp-content\/uploads\/2025\/09\/pdf-61-full.jpg", "name": "sample", "alt": "" } ], ... }Blaze campaign creation request before
{ "origin": "wc-android", "origin_version": "23.2", "target_urn": "urn:wpcom:post:248546480:62", "type": "product", "payment_method_id": "PW-15849315", "start_date": "2025-09-19", "end_date": "2025-09-26", "time_zone": "Africa/Casablanca", "budget": { "mode": "daily", "amount": 5.0, "currency": "USD" }, "site_name": "Transform Your PDFs!", "text_snippet": "Unlock the power of PDF images like never before. Explore now!", "cta_text": "Discover More", "target_url": "https://fortunately-square.jurassic.ninja/product/pdf-image-product/", "url_params": "", "main_image": { "url": "https://fortunately-square.jurassic.ninja/wp-content/uploads/2025/09/sample.pdf", "mime_type": "application/pdf" }, "targeting": { "locations": [], "languages": [], "devices": [], "page_topics": [] }, "is_evergreen": true, "objective": "sales", "accepted_tos": true }Blaze campaign creation request after the fix
{ "origin": "wc-android", "origin_version": "23.2", "target_urn": "urn:wpcom:post:248546480:62", "type": "product", "payment_method_id": "PW-15849315", "start_date": "2025-09-19", "end_date": "2025-09-26", "time_zone": "Africa/Casablanca", "budget": { "mode": "daily", "amount": 5.0, "currency": "USD" }, "site_name": "Transform Your PDFs!", "text_snippet": "Unlock the power of PDF images like never before. Explore now!", "cta_text": "Discover More", "target_url": "https://fortunately-square.jurassic.ninja/product/pdf-image-product/", "url_params": "", "main_image": { "url": "https://fortunately-square.jurassic.ninja/wp-content/uploads/2025/09/pdf-61-full.jpg", "mime_type": "image/jpeg" }, "targeting": { "locations": [], "languages": [], "devices": [], "page_topics": [] }, "is_evergreen": true, "objective": "sales", "accepted_tos": true }Steps to reproduce
Testing information
The tests that have been performed
The above.
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.