solved Image URL for use in CSS

TiG
TiG
@tig
5 years ago
184 posts
Is there a way to generate a variable like $jrCore_img_url to be used in CSS for a module?

For example: on a user module: ntMyModule, I would like to have a variable to allow:

background: url("{$ntMyModule_img_url}/myimage.png");

Thanks


--
TiG

updated by @tig: 03/04/20 09:26:57AM
michael
@michael
5 years ago
7,715 posts
Yeah that's available check out any of the jr skins, they all should have something like this in them:
background: #111111 url("{$jrBeatSlinger_img_url}/jp-play.png") no-repeat scroll center center;
Thats from the jrBeatSlinger skin.

The image should go in the skins /img folder.
TiG
TiG
@tig
5 years ago
184 posts
Hi Michael

I am trying to pull the image from the img folder for a custom module. Apparently I need to do something to cause that module url (myModule_img_url) variable to be generated. jrAudio has such a variable but I do not see where it was generated.

Thanks


--
TiG
michael
@michael
5 years ago
7,715 posts
Hi Tig,

Not getting you, sorry.

If you have a
/modules/ntMyModule/img/myimage.png
file, then you use {$ntMyModule_img_url} in the CSS file at /modules/ntMyModule/css/mycss.css

That file should be registered in the _init() function
/modules/ntMyModule/include.php
function ntMyModule_init(){
jrCore_register_module_feature('jrCore', 'css', 'ntMyModule', 'mycss.css');
.....
}

so it will be included in the system generated single css file that has a long name and shows in the meta like:
<link rel="stylesheet" href="http://your-site.test/data/cache/ntYourSkin/26f48dab94ba6e342990f9162b2dec4a.css" media="all" type="text/css">

The variable should be being replaced.

--edit--
couple of typos and clarity.
updated by @michael: 12/02/19 09:37:34PM
TiG
TiG
@tig
5 years ago
184 posts
Michael

You were understanding just fine. Basically the system works as I was expecting it to work. I must have mistyped the variable when I first tried to do this (before I started trying other things) because what you describe is exactly how I had things set up. I just did it again and it works as expected.

Thanks!


--
TiG
michael
@michael
5 years ago
7,715 posts
Awesome! :)

Tags