Allow image paths to be relative to a module or theme

Created on 29 March 2021, about 3 years ago
Updated 15 March 2024, 4 months ago

Problem/Motivation

If you are storing your images inside a module or theme, having to reference the entire image path will cause problems in cases where the path from the root of the site is not fixed. Examples would be:

  • You want to have a copy of the module/theme containing the image in an "overriding" folder, for development, or in a multi-site environment where you have one or more sites that should get a different version/branch than the others
  • Server has different path structure than your development environment
  • Different domain names have different path structures

While technically it is possible to create a different configuration for each environment, for maintainability it would be nice if they could all use the same configuration.

Steps to reproduce

Put an image inside a module/theme in sites/all/modules. Reference the path to that image. Copy the module/theme into sites/sitename/modules and replace the image file with something that looks different but has the same filename. Note that, because you are using an exact path, the browser still shows the version of the image from the original folder.

Proposed resolution

Add an "image path base" field to the configuration, with "use as shown" as the default (allowing full backwards compatibility), that lets you select a module or a theme to use as the base path for the image URL.

Remaining tasks

I have a working prototype of this - it will be turned into a patch shortly.

User interface changes

Adds an image path base field, which defaults to "use as shown" for backwards compatibility.

API changes

n/a

Data model changes

Adds an image path base field.

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada kpaxman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024