Skip to content

Conversation

@spivurno
Copy link
Contributor

@spivurno spivurno merged commit c24a3b9 into master Sep 19, 2025
0 of 3 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a singleton GW_CID_Image_Handler that hooks into WordPress/Gravity Forms email flow to detect src="cid:..." references, resolve local image paths via several strategies, embed them inline via PHPMailer, and rewrite the email body to use generated CIDs. Exposes gw_cid_image_handler() to initialize the handler.

Changes

Cohort / File(s) Summary
CID image handler feature
gravity-forms/gw-cid-image-handler.php
Adds GW_CID_Image_Handler singleton with get_instance(), init(), process_cid_images($phpmailer), and a private resolver for CID paths. Hooks into initialization and PHPMailer to scan email HTML, map CID URLs to local files, embed images with correct MIME, and update the body. Adds global gw_cid_image_handler() bootstrap.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant WP as WordPress
  participant GF as Gravity Forms
  participant H as GW_CID_Image_Handler
  participant PM as PHPMailer
  participant FS as Filesystem

  WP->>H: gw_cid_image_handler() on load
  activate H
  H->>WP: add hooks (init, phpmailer_init)
  deactivate H

  WP->>GF: Trigger email send
  GF->>PM: Prepare PHPMailer instance
  WP->>H: phpmailer_init(PM)
  activate H

  H->>PM: Read HTML body
  alt Body contains src="cid:..."
    loop For each CID reference
      H->>FS: Resolve path (URL->path, WP_CONTENT_DIR, uploads, recursive search)
      alt File found
        H->>PM: AddEmbeddedImage(path, generated CID, mime)
        H->>PM: Rewrite body with embedded CID
      else File not found
        H-->>PM: Skip embedding for this CID
      end
    end
    H->>PM: Ensure isHTML before send
  else No CID references
    H-->>PM: No changes
  end
  deactivate H

  PM-->>GF: Send email with embedded images
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dave/gw-cid-image-handler

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b6d8f6 and 363a71e.

📒 Files selected for processing (1)
  • gravity-forms/gw-cid-image-handler.php (1 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@spivurno spivurno deleted the dave/gw-cid-image-handler branch September 19, 2025 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants