Skip to content

FormBuilder support image URL upload#32780

Closed
MegaphoneJon wants to merge 1 commit into
civicrm:masterfrom
MegaphoneJon:imageurl-fb
Closed

FormBuilder support image URL upload#32780
MegaphoneJon wants to merge 1 commit into
civicrm:masterfrom
MegaphoneJon:imageurl-fb

Conversation

@MegaphoneJon

Copy link
Copy Markdown
Contributor

Overview

It's not currently possible to upload an "Image URL" field (aka contact record's headshot) via FormBuilder.

Before

Broken link, no image

After

Successful upload

Comments

This is a variation on #28840, adapted to handle merge conflicts and without style issues.

@civibot

civibot Bot commented May 12, 2025

Copy link
Copy Markdown

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot Bot added the master label May 12, 2025
@seamuslee001

Copy link
Copy Markdown
Contributor

Jenkins re test this please

@mmyriam

mmyriam commented May 23, 2025

Copy link
Copy Markdown
Contributor

Jenkins re test this please

@kamouraska50

kamouraska50 commented May 23, 2025

Copy link
Copy Markdown

Got this error testing this PR:
Deprecated function: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in CRM_Utils_File::getImageURL() (line 976 of sites/all/modules/civicrm/CRM/Utils/File.php).

@kcristiano

Copy link
Copy Markdown
Member

I've done an r-run on this as well as #28840

  • CiviCRM master (6.4.alpha)
  • WP 6.8.1
  • php 8.3

The file entity gets updated correctly with the image uri, but the contact summary screen shows

image

linked to https://example.org/wp-admin/1 instead of the correct image URL.

@kcristiano

Copy link
Copy Markdown
Member

@MegaphoneJon I saw this mentioned - Can you add notes (or a sample form) from your testing? I am happy to re-test if you have this working.

@braders

braders commented Jul 20, 2025

Copy link
Copy Markdown
Contributor

I've tested this (and am very keen to see this issue resolved - it'd be incredibly useful for a project I'm currently working on 😄)

I did get the same behaviour as kcristiano (the image showing as a number on the contact summary screen). However, I get the correct behaviour if I change the if statement to (isset($entityId) && $this->getFieldName() === 'image_URL').

I'm not sure if there are legit cases where getFieldName() would return Image URL, or if it should always be image_URL. I suspect the later.

@colemanw

Copy link
Copy Markdown
Member

@MegaphoneJon did you see this feedback ^

@braders

braders commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

I have one more bit of feedback on this. The other civicrm_api4 calls in Civi\Api4\Action\Afform\SubmitFile all do 'checkPermissions' => FALSE. I therefore think the call to update the contact also needs 'checkPermissions' => FALSE. This allows for public forms to allow contacts to update their own contact image.

From a security perspective I think this is ok, as I don't think form processors will run unless the user has the correct permissions against the form.

@colemanw

colemanw commented Jul 25, 2026

Copy link
Copy Markdown
Member

The feedback on this PR never got addressed so I've reopened it as #36326

FYI @MegaphoneJon

@colemanw colemanw closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants