Skip to content

Conversation

@hichamboushaba
Copy link
Member

@hichamboushaba hichamboushaba commented Sep 19, 2025

Closes WOOMOB-1348

Description

This PR fixes an issue where the app could send a PDF URL in the main_image.url field when creating a campaign, and main_image.mime_type set to application/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

  1. Creating a website with the issue is not a straightforward process, so ping me in a DM to share a test store.
  2. Open the app.
  3. Create a Blaze campaign using the default AD image.

Testing information

  • Confirm the PR fixes the issue.

The tests that have been performed

The above.

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@hichamboushaba hichamboushaba added type: bug A confirmed bug. feature: blaze Related to the Blaze project labels Sep 19, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 19, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit91fa844
Direct Downloadwoocommerce-wear-prototype-build-pr14642-91fa844.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 19, 2025

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit91fa844
Direct Downloadwoocommerce-prototype-build-pr14642-91fa844.apk

@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1348-fix-blaze-pdf-files-failure branch 2 times, most recently from 6a98aae to 5a9d0e9 Compare September 22, 2025 10:05
@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1348-fix-blaze-pdf-files-failure branch from 5a9d0e9 to 91fa844 Compare September 22, 2025 10:06
@hichamboushaba hichamboushaba marked this pull request as ready for review September 22, 2025 12:06
@AdamGrzybkowski AdamGrzybkowski self-assigned this Sep 23, 2025
Copy link
Contributor

@AdamGrzybkowski AdamGrzybkowski left a 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?

@hichamboushaba hichamboushaba added this to the 23.4 milestone Sep 23, 2025
@hichamboushaba hichamboushaba merged commit 819da69 into trunk Sep 23, 2025
18 checks passed
@hichamboushaba hichamboushaba deleted the issue/WOOMOB-1348-fix-blaze-pdf-files-failure branch September 23, 2025 09:41
@hichamboushaba
Copy link
Member Author

Any reason you haven't added a milestone?

Thanks for the review @AdamGrzybkowski, I just missed it 🙂

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

Labels

feature: blaze Related to the Blaze project type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants