Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set background css image in phpstorm - "cannot resolve file"

I have an image that I'd like to set as a background in a Laravel 3 project - background-image: url("public/img/find-a-table.png");

But it's saying "cannot resolve find-a-table.png" in phpStorm even though I definitely have the image file added to that directory.

Do I need to change something to have it find my image in that directory? In any other typical web app, this would be quite trivial to do so I don't know if I'm missing something.


this site shows I don't need the quotes around the path? I've tried that too but that doesn't fix it. They use:

background: url(images/bg.jpg) no-repeat center center fixed; without quotes

like image 622
user3871 Avatar asked Apr 22 '15 18:04

user3871


2 Answers

phpStorm does not tell you, that your browser will not see the given file. It just tells that phpStorm itself does not see the file.

You have to tell phpStorm where the relative path(es) start(s).

To do so, open your project file structure (cmd + 1 on Mac), right click on your (public accessible) root directory (public), then Mark Directory as > and Resource Root. After couple of seconds the error message should disappear.

like image 76
Alexander Bondar Avatar answered Sep 24 '22 23:09

Alexander Bondar


Here is the fix:

1- Right-click on your (public accessible root directory) where you're sourcing the images from.

2- Scroll down to Mark Directory as

3- Choose Resource Root

enter image description here

like image 26
Jonca33 Avatar answered Sep 23 '22 23:09

Jonca33