Background image does not appear in some views CODEIGINITER

I am new to Codeigniter and php and web development so this could have a really simple solution.

I have set a background image in a main_layout that is called in every view (I had the code for the background on each page instead of on the main_layout and it made no difference). The image works just fine in the majority of my views. The problem is that the image does not appear on any view that has a route with a variable (I don't know the correct name for it but something like: " $routes->get('/edit/(:alphanum)', 'Main::edit/$1') ").

 <div class="bg-image overflow-hidden " style="
    background-image: url('../public/assets/images/aspersor_fundo_joao_vertical.jpg');
    background-size: cover;
    height: 100vh;">

        <div class="mask" style="background-color: rgba(0, 0, 0, 0.3); height:100vh;">

If I change the class from "bg-image" to "bg-success" the background turns green, so the problem is probably in the loading of the image but I have no idea why it works in every other view but does not work on the views with variable url.

I had a similar problem with filters until I finally figured out that I had to put a "*" on the end of the route in order for the filter to access every possible combination of '/edit/(:alphanum)' but now I just can't find a solution.

So, I narrowed down the problem, the thing is: the path for the image on the page that has pretty url is "public/assets/images/aspersor_fundo.jpg" (this is confirmed uppon inspection of the page that shows the image). The path for the image on the page that does not show the background is "public/public/assets/images/aspersor_fundo.jpg". Keep in mind that my background is only written once, and then I call that same code on every view to display the background everywhere. The extra public comes from nowhere. I can fix my issue by displaying the background image in each of my views and removing the "public" from the path on the views that are presenting this problem (If I just remove the "public" from every path than the image shows where it was not showing and stops where it was working). But I still would like an explanation or other way to solve it.

Upvotes: 0

Views: 50

Answers (0)

Related Questions