Skip to content

Commit

Permalink
WPCIVIUX-190 Support absolute URLs for image sources in the Event Cal…
Browse files Browse the repository at this point in the history
…endar
  • Loading branch information
agileware-iris committed Dec 9, 2024
1 parent 81ba04d commit 1bececa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rest/json-all-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ protected function get_events_all() {
);

if(!empty($image_src_field) && !empty($event[$image_src_field])) {
$image_url = $upload . '/' . $event[$image_src_field];
// If the image source is an absolute URL, just return that.
// Otherwise, append the relative path to the upload directory.
if (str_starts_with($event[$image_src_field], 'http')) {
$image_url = $event[$image_src_field];
} else {
$image_url = trailingslashit($upload) . ltrim($event[$image_src_field], '/');
}

$event_obj['extendedProps']['file.uri'] = $event[$image_src_field];
$event_obj['extendedProps']['image_url'] = $image_url;
Expand Down

0 comments on commit 1bececa

Please sign in to comment.