how can i fix image src - html

When I use this code, it's right :
img(src="http://localhost:3030/uploads/customerimages/42.jpg", alt="image")
but this code gives 404 error :
img(src="./uploads/customerimages/42.jpg", alt="image").
The second one output is http://localhost:3050/information/edit/uploads/customerimages/42.jpg
but need http://localhost:3030/uploads/customerimages/42.jpg.
http://localhost:3050/information/edit is current route.
How can i solve this?

Just remove dot before url
Use like
img(src="/uploads/customerimages/42.jpg", alt="image")

Related

When I load a view from my controller some html functionality is lost

So when I load a view like this:
Address bar reads:
"http://localhost/Mywebsite/private_area"
the view is called from the index function of the controller "private_area", and it works fine. However when I call the page using a function "profile" such that the address bar reads:
"http://localhost/Mywebsite/private_area/profile"
the view loses certain functionality such as the toggle buttons dont work, and the src= doesnt work either. The code for the index function and profile function is identical.
Very confused, any ideas?
Here is some related code:
Controller "Login" Redirects using:
redirect ('private_area');
This calls route
$route['private_area'] = 'private_area';
This calls controller Private Area/Index which has the following code:
$this->load->model("Profiles_model");
$profiledata["fetch_profiledata"] = $this->Profiles_model->fetch_profiledata();
$this->load->view('templates/header_pa');
$this->load->view('pages/page-profile', $profiledata);
$this->load->view('templates/footer');
This works fine and displays the Page-profile view perfectly.
But if I go to another view, and then come back to Page-profile view using
Profile
Which call controller "Private_area" and function "Profile"
function profile()
{
$this->load->model("Profiles_model");
$profiledata["fetch_profiledata"] = $this->Profiles_model->fetch_profiledata();
$this->load->view('templates/header_pa');
$this->load->view('pages/page-profile', $profiledata);
$this->load->view('templates/footer');
}
The main view loads, but the src tags dont work, neither do the toggle buttons.
If you are adding the <?=base_url();?>to your image, and any other path, you'll be good.
In case you are adding variables to your function you will have the same problem all over again.
For example your image should look like this:
<img src="<?=base_ur();?>assets/img/demo/avatar1.jpg">
Hope this helps.
I would say you are using relative paths for your CSS and/or Javascript files without the base_url() in front.
Are you getting any 404s in the developer tools? They usually tell you where the problem is.
A correct way of embedding JS & CSS would be:
<link rel="stylesheet" href="<?=base_url();?>/assets/css/bootstrap.min.css">
<script src="<?=base_url();?>assets/js/bootstrap.min.js"></script>
AnPS: So I was able to solve at least part of the problem like this:
The offending code was:
<img src="assets/img/demo/avatar1.jpg">
It would generate the following error:
GET http://localhost/Mywebsite/private_area/assets/img/demo/avatar1.jpg 404 (Not Found)
As it was reading the Controller - "Private_area" as a folder, so I just added ../ to the offending code
<img src="../assets/img/demo/avatar1.jpg">
I fixed the Toggle Buttons using a similiar approach by adding ../ to the script like this:
<script src="../assets/js/plugins.min.js"></script>
<script src="../assets/js/app.min.js"></script>
This worked, but did I do it right? Or is this just a bad "work-around"?

VS code Error : settings.json property expected (bug)

enter image description here
When I use VS Code, a problem notice likes that(in the above image) is printed.
Although I want to fix it and really don't want to see it, I can't find any way to fix.
I am very painful about just seeing that error message all the time.
Please give me some helps.
You opened a { parenthesis at line 2784 and didn't close it. You should close it. --> }
Also, you have an extra comma , at 2793 that you have to remove.
Not use {}, because you may already mess your settings.json before.
so my suggestion as follows:
// in/your/settings.json/file
...
setting0_name:[setting0.0, setting0.1],
seting1_name : settings,
...

Grunt zetzer options

I am trying to pass a class to an include with grunt zetzer but I am not able to take it into the include.
I mean I invoque the part
{{= it.include("common/entity-slider-hero.html", {"class" : "extraclass","link" : "http://www.optionlink"}) }}
It works fine, but how do I get the option in the include?... something like
<div class="hero-slider {it.{class}} " >
Any help is appreciated
finally I found the solution the correct way was {{= it.class}}

Adding image src path in cakephp

Iam creating an image link in cakephp using html tag, i have a problem with adding src path.
I tried
<a href="#today1" id="lnk3">
<img src="/iserprofiles/app/webroot/img/todaysallocation.png">Todays Allocation</a>
but image is not loaded. if anybody know please reply. i know that we can also create image link using cakephp, but i faced one problem
i u sed this code
<?php echo $this->Html->link($this->Html->image('todaysallocation.png',
array('width' => '200', 'height' => '45')) ,
'#today',array('escape' => false));?>
i dont want to use any controller or action as url, simply i just added '#today',
but my problem is i need to add one id for this. how can we done this????
Check in Your browser patch: localhost/iserprofiles/app/webroot/img/todaysallocation.png
, but i think the problem is in Your .htaccess file, because path to image will look like localhost/iserprofiles/img/todaysallocation.png

Setting proper relative URL

If I am on the following page:
http://subsite.mysite.com/sites/department/class/SitePages/Home.aspx
and want to have a link to
http://subsite.mysite.com/sites/department/SitePages/Home.aspx
i.e. I want to keep /sitepages/home.aspx and move it one step up in the hierarchy
and not hard code http://subsite.mysite.com/sites/department/
Is this possible?
Thanks in advance.
Try:
My Link or
My Link