CiviCRM: v5.57.3 (Currently waiting for a 3rd Party plugin to be updated to be compatible with the latest version.) WordPress: v6.2.2
We have a custom field attached to CiviEvents that lets the team upload an image to be used when outputting the Event on the public front end.
We are building the front end outside of CiviCRM by using API4 to fetch data.
We can retrieve the file details via joining to the File on the custom field.
{
"id": 1,
"Events_.Image": 1234,
"file.id": 1234,
"file.file_type_id": null,
"file.mime_type": "image/png",
"file.uri": "example.png",
"file.document": null,
"file.description": null,
"file.upload_date": "2023-07-05 16:00:00",
"file.created_id": null
What we are having issues with is taking this information and getting a full URL to be used inside an <img>
tag. eg, https://www.example.test/app/uploads/civicrm/custom/example.png
.
I'd expect a function along the lines of get_image_url(1234);
but cannot find anything within the CiviCRM documentation.
Any guidance is much appreciated.