Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

image() function - can't reference module specific images #1017

Open
boblennes opened this issue Apr 7, 2014 · 1 comment
Open

image() function - can't reference module specific images #1017

boblennes opened this issue Apr 7, 2014 · 1 comment

Comments

@boblennes
Copy link
Contributor

I was trying to write a Bonfire "upload profile image" module that includes images under [modulename]/assets/images but per the documentation:
Whenever you use one of the asset rendering methods, like css(), js(), and image(), it will search in each of those folders (as well as a folder named by the asset type under those folders, ie. 'css') in the order listed above. Note that it only looks within the module if it was added via add_module_css() or add_module_js().
There's no method or way with modules to reference the module image in an image tag unless you manually copy it to the public folder. Shouldn't there be some way to include images in a module?

@mwhitneysdsu
Copy link
Contributor

I would imagine to support this a writable directory in the /public/assets/images/ directory would be required to which module images could be copied (or they'd have to be copied into the /assets/cache/ directory).

The way add_module_js() and add_module_css() work is by combining all of the module JS/CSS files into the cached JS/CSS file for the current module. This actually causes some problems (if you call the methods for different files in different locations within the same module, some files may not be included), and I was considering a similar solution: copy the original JS/CSS files into a given location (and use those files for the checks that determine whether combined files need to be updated).

If a modules directory was added to the /assets/cache/ directory, the assets library could probably replicate the directory structure there (i.e. /assets/cache/modules/{moduleName}/{images/js/css}), then reference the cache (for images, and, if the option to combine files is disabled, or as the source for combining the files when it is enabled).

Unfortunately, since the Assets library's image() method doesn't really do much at the moment (you pass it the path and attributes, it builds the img element), this would probably require a new method in the library (or at least a new parameter to trigger the new functionality).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants