Benas Radzevicius
Benas Radzevicius

Reputation: 377

Can't get an image asset

Why i can't get an image to work. I'm trying this:

background-image: url(jBootstrap/images/ui-icons_222222_256x240.png);

and it doesn't work. When i'm trying to access it trought URL i get an error:

Asset [stylesheets/jBootstrap/images/ui-icons_222222_256x240.png] was unable to be processed.

Can't get any images, tried in many variations of directories and still doesn't work. When i'm doing this on plain html-css it works perfectly, but not in laravel. What am I doing wrong ?

btw, i'm using Basset if it helps.

EDIT 1

Also including the additional information about a partial structure of my public folder and html link generated by basset:

when including the css file, in source code i see:

<link rel="stylesheet" type="text/css" href="http://localhost/Job/worker/myapp/public/7n3C5wypAmTi8VT8/application/stylesheets/main.css" />

Edit 2

Adding my public/.htaccess file:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Edit 3

Tried another way:
public/stylesheets/main.css
public/stylesheets/abc.jpg
in main.css I have code: body { background-image: url('abc.jpg') } and i'm getting nothing ...

Please help, struggling 2 days now ...

Upvotes: 0

Views: 1751

Answers (3)

automaticAllDramatic
automaticAllDramatic

Reputation: 2063

Try using setArguments('../') on your collection

'collections' => array(

        'application' => function($collection) {
            $collection->add('../vendor/twitter/bootstrap/less/bootstrap.less')->apply('Less');

            $directory = $collection->directory('assets/stylesheets', function($collection) {
                $collection->add('main.css');
            })->apply('UriRewriteFilter')->setArguments('../')->apply('CssMin');
        }
 ),

This did the trick for me.

Upvotes: 0

Benas Radzevicius
Benas Radzevicius

Reputation: 377

Found the problem... It was Basset package, it wat required to put $collection->apply('UriRewriteFilter'); into configurations.

Upvotes: 1

Mike Rock&#233;tt
Mike Rock&#233;tt

Reputation: 9007

I would naturally assume that one (or both) things are incorrect here:

  1. Your .htaccess file is not checking for existing files when rewriting. Check to see if RewriteCond {%REQUEST_FILENAME} !-f exists in that file.

  2. You are not requesting your background image from the root, i.e. absolutely. Try requesting the resource using a leading slash. For example, instead of calling foo.png, try calling /foo.png.

Upvotes: 0

Related Questions