<img src= url> Not showing image on index.php - php

I used following code on index.php and it is 100% working on localhost, but not appear image on live server "www.chitthu.co".
<div class="block">
<img src="/img/step-1.png" style="width:20%; height:20%; margin:5px;">
<h3>Join Chitthu</h3>
<p>
Signing up takes two
minutes <br>to get a Chitthu account.
</p>
</div>

step-1 to Step-1.
It seems that your server is case sensitive, which means S and s is very different.

Open your directory :
www.chitthu.co/img/
You don't have this image:
www.chitthu.co/img/step-1.png
You have:
www.chitthu.co/img/Step-1.png
Your directory:

Try this Step-1 http://www.chitthu.co/img/Step-1.png
<img src="http://www.chitthu.co/img/Step-1.png" alt="Step-1"/>

Related

Can't get path to image in HTML

Alright, I have a file named slider.php which contains a bootstrap slider and I'm inserting pictures inside the slider but I can't figure out the correct way of writing the path to the pictures
<div class="carousel-inner">
<div class="item active">
<img class="slide-image" src="" alt="">
</div>
<div class="item">
<img class="slide-image" src="" alt="">
</div>
<div class="item">
<img class="slide-image" src="" alt="">
</div>
The slider.php is in this location ecomcopy/resources/front/slider.php
and the pictures are in ecomcopy/resources/img/
I tried everything and I can't get the correct pictures path
Can someone help?
The way paths work is to go "up" to parent folders until you're at a common ancestor. Then go back down naming folders until you get to the file you're referencing.
ecomcopy/resources/front/slider.php
ecomcopy/resources/front/ (start)
ecomcopy/resources/ (up 1) ../
ecomcopy/resources/templates/ (down to folder) templates/
ecomcopy/resources/templates/img/ (down to folder) img/
ecomcopy/resources/templates/img/yourimage.png
(down to file) yourimage.png
result: ../templates/img/yourimage.png
should be ../../img/image_name.png
It would be much easier (at least on a live server setting) to just specify absolute paths for your URLs.
For example, the following HTML is all that is needed to serve your images:
<img src="/ecomcopy/resources/templates/img/yourimage.png" />
There is no real need to worry about complicated relative file paths.

PHP Includes are chopping when viewing "localhost" on Virtual Machine

Here is my setup: I am coding on a Mac with VMware Fusion loaded (running Windows 8 on the VM). The VM has IIS running on it so that I can do local testing of my code (written in Edge Code/Brackets). I test the code by pointing my Mac browser at [ip address]:[port]/[file]. This works fine usually, but I am running into a problem with my includes.
Here is the structure:
[index.php]
<body>
<?php require '/Library/Includes/header.inc.php'; ?>
hello
[header.inc.php]
<div class="container_16">
<div class="grid_6">
<img src="http://placehold.it/298x48" alt="Logo" />
</div>
<div class="grid_10">
<?php include 'eyebrow.inc.php'; ?>
</div>
[eyebrow.inc.php]
<ul id="eyebrow-links" class="h-list">
<li><img src="http://placehold.it/24x24" alt="User Avatar" /></li>
<li>My Profile</li>
<li>English</li>
<li>Logout</li>
</ul>
This is the output when I view the source from my Mac
<body>
<div class="container_16">
<div class="grid_6">
<img src="http://placehold.it/298x48" alt="Logo" />
</div>
<div class="grid_10">
<ul id </div>
</div>
hello
It's chopping out a bit of my include. When I test this same code on my Windows Machine, it behaves normally and returns the entire include. Has anyone else run into this problem? Any idea what is happening? I appreciate your help!
Jason
The issue seems to be stemming from my first li element. It might be the reference to placehold.it that is breaking the include. Not sure why it only seems to have problems on my Mac and not my PC, but at least I'm narrowing down the issue.
UPDATE
Nevermind. It just continues to break if I have 4 li elements. Abandoning the issue and just ignoring it. Sorry!

How to correctly use get_template_directory_uri() WordPress function to load an image that is in a subfolder of my theme?

I am pretty new in WordPress and I have the following doubt about how to insert in my homepage an immage that is in a subfolder into my theme directory.
So I have the following situation: Into my custom theme directory I have the following folder that contains a jpg immage: /assets/img/flexslider/flex-1.jpg
Now in my header.php file I have something like this:
<li>
<img src="assets/img/flexslider/flex-1.jpg">
<div class="flex-caption">
<p class="flex-caption-text">
<span>Lorem ipsum</span><br>
<span>sit dolor</span><br>
<span>adipiscing elitur</span>
</p>
</div>
</li>
Obviously, when I load the page, the immage flex-1.jpg is not loaded because there is not the right path (infact using FireBug I obtain that it try to load the assets/img/flexslider/flex-1.jpg immage) so I think that I could use the absolute path but this is pretty orrible !!!
So I am thinking to use the get_template_directory_uri() function provided from WP to do this and I have try to change the previous code in this way:
<li>
<img src=<?php get_template_directory_uri().'/assets/img/flexslider/flex-1.jpg' ?>>
<div class="flex-caption">
<p class="flex-caption-text">
<span>Lorem ipsum</span><br>
<span>sit dolor</span><br>
<span>adipiscing elitur</span>
</p>
</div>
But don't work and using FireBug I can see that load nothing, infact in my brower source code I have:
<img src="">
Why don't work? What am I missing?
Tnx
Andrea
I hope it will work:
<img src="<?php echo get_template_directory_uri(); ?>/assets/img/flexslider/flex-1.jpg" />
If your assets folder inside theme.
please try :
<img src="<?php print(get_template_directory_uri()); ?>/assets/img/flexslider/flex-1.jpg" />
just check for slash, if double before "assests", remove static one.
You can also use:
<img src="<?php bloginfo('template_url'); ?>/images/yourimage.jpg">

What is wrong with my PHP code?

I have been seriously been looking at this forever! I'm going out of my mind And can't figure out why my images are not displaying in my custom made footer.
I have firefox with firebug and it is simply saying that the url is failing to load. so I copy and pasted a url to an image that is currently working and is being shown via the background property in CSS just fine. (thats the top one that says dakota jones). copy and pasting the exact img src proves it still not to work.
my folder is images. My functions.php is right outside. the hierarchy is correct. what the heck?? The testing text in the p tags work just fine. uhuhuhu
Somebody help me! I'm using wp and genesis theme.
add_action('genesis_before_footer', 'include_sponsors');
function include_sponsors() { ?>
<div class="sponsors">
<p>This is testing text</p>
<img src="images/dakotajonesheader3.jpg" alt="Smiley face" height="42" width="42" />
<img src="images/tfobw.png" />
<img src="images/basskingbw.png" />
<img src="images/bighawgbw.png" />
<img src="images/kbw.png" />
<img src="images/mccoybw.png" />
<img src="images/nfcbwpng" />
<img src="images/rayjusbw.png" />
<img src="images/rrbw.png" />
</div>
<?php }
Use WordPress' inbuilt function:
<?php
bloginfo('template_directory'); ?>/images/dakotajonesheader3.jpg
?>
.. which will reference /wp-content/themes/your-theme/images/dakotajonesheader3.jpg
Wordpress dynamically rewrites URLs, so the URL you use to access a page is not the same as the path to the scripts that are running on the server. So you might request your page with example.com/Home. But your images are not stored in example.com/Home/images, which is where you're telling your browser to look. They're stored in example.com/wordpress/wp-content/themes/your_theme/images. So you have to give the absolute path to the images to the browser in your <img> tags.
Carson is correct, and you can use absolute paths to your images. Alternatively, if you want to avoid using absolute paths, you can call your images using bloginfo('template_directory');
For example:
<img src="<?php bloginfo('template_directory'); ?>/images/dakotajonesheader3.jpg" alt="Smiley face" height="42" width="42" />

Display image using absolute path

I am using uploadify to upload img to server at the time of upload i saved absolute path to the data base its like:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
now I want to display the same in browser the following method does not work
<div id="photos">
<h3>Photo title</h3>
<P class="like">Like </P>
<p class="date">date </p>
<p class="pclear" />
<div id="image">
<img src="<?php echo $result_set['path']; ?>" />
</div>
<p class="about">about image goes here</p>
</div>
above code doesn't work. when I edit the path manually to uploads/logo2.jpg it works perfectly
how can I resolve this problem?
You need to use an url, not a path.
This:
/var/www/html/workbench/photogallery/uploads/logo2.jpg
is a physical path, the address on that server where the image is found. You need to use an url available for your visitors. I guess that you have a name mapped to that server (something like localhost or www.example.com).
From the structure I guess that your url would be something like
http://www.example.com/photogallery/uploads/logo2.jpg
where www.example.com is the base url you are using to get to that application
Try this:
<img src="/photogallery/uploads/<?php echo basename($result_set['path']) ?>" />
Try this it works for me and keeps the location of the images hidden from the browser.
<img src='fake.php' style='max-width:90px;'/>
Create a file called fake.php as follows
<?php
$thePic = "/var/www/html/workbench/photogallery/uploads/logo2.jpg";
$image = imagecreatefromjpeg($thePic);
// Output image and free up the memory
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
?>
You can adjust the code in the fake.php file to retrieve the location of $thePic from posted data or database, etc.

Categories