-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #561 from compucorp/PCHR-4281-image-display-fixes
PCHR-4281: Image Display Fixes
- Loading branch information
Showing
6 changed files
with
147 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Drupal\civihr_employee_portal\Helpers\UrlHelper; | ||
|
||
/** | ||
* Remove photo=0 from all contact image URLs | ||
* | ||
* It was added to fix a warning in CiviCRM, but this warning is no longer | ||
* generated and the addition of photo=0 causes problems for image display | ||
*/ | ||
function civihr_employee_portal_update_7042() { | ||
civicrm_initialize(); | ||
$contacts = civicrm_api3('Contact', 'get'); | ||
$contacts = CRM_Utils_Array::value('values', $contacts, []); | ||
|
||
foreach ($contacts as $contact) { | ||
$imageUrl = CRM_Utils_Array::value('image_URL', $contact); | ||
|
||
if (!$imageUrl) { | ||
continue; | ||
} | ||
|
||
if (strpos($imageUrl, 'photo=0') === FALSE) { | ||
continue; | ||
} | ||
|
||
$newImageUrl = UrlHelper::removeQueryValueFromUrl($imageUrl, 'photo'); | ||
|
||
civicrm_api3('Contact', 'create', [ | ||
'id' => $contact['id'], | ||
'image_URL' => $newImageUrl, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters