Build 401 - System file model now returns a fully qualified path

Release Note 7

An inconsistency in the File model has been corrected, as a result the getPublicPath method will no longer return a relative path.

As of octobercms/october@5aa351f, getPublicPath() as called on System\Models\File objects no longer returns a relative path to locally-stored resources. It now returns a full URL for both locally-stored resources and CDN-stored resources (previously only returned a full URL for CDN-stored resources).

This change was necessary due to the inconsistency with how getPublicPath() handled local resources vs. external resources. However, it may cause issues for code that assumes that this method will return a relative path always.

Action Required

Update any references in your code that assumes that calls to System\Models\File->getPublicPath() will return a relative URL. This could include examples that are incorrectly using the |media Twig filter for file objects:


{{ post.featured_images.first.path|media }}

Should be replaced by:

{{ post.featured_images.first.path }}

Another use might be in a API endpoint that returns the value from getPublicPath() and the consumer of the API (an app for example), assumes a relative URL and hardcodes a concatenation of the domain and 'relative' path.


// API Endpoint:
return json_encode([
    'featured_image' => $featuredImage->getPublicPath();

// API Consumer
$data = json_decode($requestContents);
$data->featured_image = '' . $data->featured_image;

Above example can be fixed by removing the code that makes the assumption that the value of getPublicPath() will be relative ($data->featured_image = '' . $data->featured_image;) and just using the value of getPublicPath() directly instead.

Related issues

comments powered by Disqus