Skip to content

Fixed: File::uri() is not consistent with other Entity types. #2300

@mikemccaffrey

Description

@mikemccaffrey

As part of building the Link formatter for the Reference module, we encountered a problem where the $entity->uri() function for file entities includes a stream wrapper identifier in the beginning like "public://field/image/imagefield_1g3q2W.png".

Right now, it tries encoding the "public://" into the url itself, creating a bad link.

Option 1: We should add a check in the url() function to check if a path starts with stream wrapper identifier, and format the resulting url using the stream wrapper.
Option 2: We should change File::uri() to be consistent with other entity types, and link to file/[fid] page instead of a direct path to the file itself.

At the time this issue was originally created, Files did not yet have pages. Now that they do, we have two options to solve this problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions