Not sure about clear way, but there is always using the File API. Themes do have other methods too. And there is 'image_url' etc. (was 'pix_url') for images.
Courses and course formats
Adding settings to course and overriding activities Moodle 3.3
This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.