Skip to content

Feature Request: Add relativePath or themePath to Asset #227

@strarsis

Description

@strarsis

Terms

Summary

Asset currently has a path() function that returns the full, absolute path to the asset.
Sometimes the path relative to the theme directory is also needed, as for add_editor_style.
Currently, additional code/library is needed to get the path relative to theme directory from the absolute path returned by the path() function.
It would be nice if also a function is added that returns the path to asset relative to the (Sage) theme directory.

Motivation

Why are we doing this?

Sometimes the path relative to the theme directory is also needed.

What use cases does it support?

add_editor_style requires either an URI (that currently cause an issue post-processing CSS in Gutenberg editor to rewrite URLs relative to stylehsheet) or a path to a local file relative to the theme directory (that doesn't cause this issue).

What is the expected outcome?

Elimination of additional code/library for making the absolute asset path (from path()) relative to the theme directory path,
so it can be used by functions like add_editor_style.

Potential conflicts / foreseeable issues

One more API function in acorn, paths and their handling shouldn't change in the foreseeable future, so once the code (and tests) for a theme-directory-relative path function is in place, no changes should be expected any time soon.
As this functionality would be requires in any theme that adds the frontend styles in the expected way (using add_editor_style), this should justify adding such an additional function.

Additional Context

https://discourse.roots.io/t/absolute-domain-relative-path-for-asset-urls-in-css/23121/4

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy