I am trying to get the full path of my image to work across the board instead of using image/blah/blah on my page I have them working with the blade template engine
{{ HTML::style('css/bootstrap.css'); }}
{{ HTML::style('css/bootstrap-responsive.css'); }}
{{ HTML::style('css/style.css'); }}
{{ HTML::script('js/jquery.js'); }}
But I am trying to use background-image for a menu bar
background-image: url(images/transparentBackground.png)
Is there a way to use Blade templates to get that image to load the full path?
If I use
background-image: url({{ HTML::script('images/transparentBackground.png'); }})
It doesnt work and returns errors.
Well, first of all, you'd want to use
url({{ URL::asset('images/transparentBackground.jpg') }})
instead of
`HTML::script()`.
That would work if you are using inline styles.
If you are trying to have blade parse a linked stylesheet however, that's just never going to work. Nor should it. In that case, you might want to look into using something like Sass and Compass. With the right configuration, you can have full paths to your images generated automatically.
I don't understand your problem very well. Why do you need a full path? This is css. Images folder has to be near a css file.
In your case try background-image: url(../images/transparentBackground.png)
-- public (folder)
---- css/style.css
---- images/transparentBackground.png
You can use helper functions Here
Here is an example of background-image using helper function
background-image: url("{{ public_path('images/bg_invoice.jpg') }}");
public_path is a helper function to the path of public folder in your Laravel app and images is the nested folder in public. Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With