Using images in a block folder for use in in-line CSS: help with path issues

Permalink
This question is an extension of a previous question. One problem solved, and another takes its place.
http://www.concrete5.org/community/forums/5-7-discussion/5.7-how-to...

I am making a block that displays images as CSS backgrounds. The images are supplied by the block itself (in a folder called images). Currently I am using view.css to handle the CSS background declarations.

My block works properly, but would be wildly more efficient if I could in-line the CSS.

Questions:
Using the images as backgrounds in in-line styles and in style tags does not work (incorrect path).
- how do I set the path so the page, which is displaying the block, can find my images folder in my block?

This question might seem convoluted or hard to understand, so if it would help, I can send the block.


Thank you

MrKDilkington
 
rge replied on at Permalink Reply
You can try this

$this->getBlockPath() . '/images'; //returns the path
//example
<?= 'style="background-image:url('. $this->getBlockPath() . '/images/name.jpg );"'; ?>
MrKDilkington replied on at Permalink Reply
MrKDilkington
Thank you for the suggestion, rge.

It put me on the right track. I found getBlockTypeAssetsURL() and so far it is working.

getBlockTypeAssetsURL() gives you concrete5 install paths like this:
/concrete5/application/blocks/

getBlockPath() gave me a system path like this:
C:/xampp/htdocs/concrete5/application/blocks/

I am hoping that getBlockTypeAssetsURL() is a recommended way to do this.