PHP images not displaying. Works in HTML [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
So I'm building a website and I'm attempting to reuse code for a scrolling photo banner.
I can mock-up everything pretty well within a strict html page. So I decided to move everything over to PHP to help make things more efficient and with the intent of eventually using MySQL in other content on the site. However, after I created my functions and began to plug everything in the photo banner disappeared. Everything else including the CSS displays beautifully. I went so far as to remove the CSS from the page to see if that was the problem. Unfortunately the images still refuse to show up. It was a direct copy->paste from the working HTML document so I'm not totally sure why the photos for the banner aren't appearing. Any advice or help would be great. Here's the code:
<html>
<style>
#import "honeysstyle.css";
</style>
<div id="container">
<div class="photobanner">
<img class="first" src="C:\wamp\www\Honeys Project\honeys\Image1.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image2.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image3.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image4.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image5.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image1.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image2.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image3.jpg" alt="">
<img src="C:\wamp\www\Honeys Project\honeys\Image4.jpg" alt="">
</div>
</div>
<?php
require( 'function.php' );
draw_titlebar();
draw_navigation();
?>
</html>

image path should be like this
<img src="http://localhost/Honeys Project/honeys/Image2.jpg" alt="">

change
<img class="first" src="C:\wamp\www\Honeys Project\honeys\Image1.jpg" alt="">
to
<img class="first" src="honeys/Image1.jpg" alt="">

Related

Prestashop: problem with logo, I don't see it in front end

website: www.e-veloce.com
I don't see logo.
I tried to change src in header.tpl to
<a href="{$base_dir}" title="{$shop_name|escape:'html':'UTF-8'}">
<img class="logo img-responsive" src="https://www.e-veloce.com/presta/img/logo.jpg" alt="{$shop_name|escape:'html':'UTF-8'}"{if $logo_image_width} width="{$logo_image_width}"{/if}{if $logo_image_height} height="{$logo_image_height}"{/if}/>
</a>
after that, I don't see logo
logo.jpg file is in presta/img/logo.jpg - so it looks good
Any ideas ?
It happens after I made SSL certification.
You have indicated an incorrect path, simply delete /presta/. Based on your code, this should work:
<a href="{$base_dir}" title="{$shop_name|escape:'html':'UTF-8'}">
<img class="logo img-responsive" src="https://www.e-veloce.com/img/logo.jpg" alt="{$shop_name|escape:'html':'UTF-8'}"{if $logo_image_width} width="{$logo_image_width}"{/if}{if $logo_image_height} height="{$logo_image_height}"{/if}/>
</a>
Use this:
src="{$base_dir_ssl}img/logo.jpg"; // https://www.e-veloce.com/img/logo.jpg
src="{$base_dir_ssl}presta/img/logo.jpg"; // https://www.e-veloce.com/presta/img/logo.jpg
I found solution. You need to do:
<img class="logo img-responsive" src="img/logo.jpg" alt="Veloce - Chemia od nas, dla Ciebie" width="367" height="54">
so i cut src with https:// only to img/logo.jpg.
Problem is popular, I hope that solution will help someone in future

How to convert an html content to wordpress

I have the following html code that tried to place in my WordPress page.
html:
<div class="hovereffect">
<img src="<?php echo get_template_directory_uri() ?>phone.jpg" >
<div class="overlay">
<h2>Hover effect 9</h2>
<a class="info" href="#">link here</a>
</div>
</div>
At the moment everything is in the site except the image that does not show.
How can I use this code WordPress in a way that it can display the image?
I think you forget to tell which place it should get the images from. And you are also forgetting a semicolon after the get_template_directory_uri();.
This is an example, but here i'm telling which folder to get the image from:
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/your_image.jpg">
you can do that but it is not a good practice to paste this code as it is in WordPress editor,
upload this image in media and get link of that image
Edit page, select text mode from top right corner of your editor and paste code these i.e
<div class="hovereffect">
<img src="http://example.com/wp-content/uploads/2016/07/img.png" >
<div class="overlay">
<h2>Hover effect 9</h2>
<a class="info" href="#">link here</a>
</div>
</div>
Here is good practice create a template for that page and write there your code.
Image replace with feature image
Heading with page title.
Detail with page content
link with page permalink.
Not enough reputation to leave a comment so I will leave this as an answer instead.
Assuming phone.jpg is at the root of your theme, you're forgetting the / (slash) before phone.jpg.
It should be
<img src="<?php echo get_template_directory_uri(); ?>/phone.jpg" >
PHP won't get parsed inside a page. Just upload the image to the WordPress media library and link to it directly.

Wordpress images don't get displayed

I started to learn Wordpress and I'm making my own theme. Within the design I have some images that are supposed to show up... but they don't.
I was using this code:
<div class="col-xs-4">
<img src="images/html_brand.jpg" class="img-responsive">
</div>
and then I found I should use php to link to my image:
<div class="col-xs-4">
<a href="#">
<img src="<?php bloginfo('stylesheet_directory'); ?>html_brand.jpg"
class="img-responsive">
</a>
</div>
But the problem is, the image still doesn't get displayed. And yes I did upload them to my web server. I have them in the directory of my theme: mythemename/images/html_brand.jpg
If you use bloginfo() to output your theme path, you need to add another /, followed by the remaining path to your image. Based on where you've placed your image, this should work:
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/html_brand.jpg" class="img-responsive">
However, bloginfo() ultimately relies on get_template_directory_uri() to work, so you might as well just use that:
<img src="<?php echo get_template_directory_uri(); ?>/images/html_brand.jpg" class="img-responsive">
Slight Correction:
bloginfo() with the specific argument of stylesheet_directory actually relies on get_stylesheet_directory_uri() to function -- get_template_directory_uri() like I originally said.
https://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/general-template.php#L439

how to add a logo on custom wordpress theme [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm building a WordPress theme from scratch at the moment and I seem to be stuck on trying to add a logo to the top left corner of the page where you would normally see the title of the page.
<h1>
<a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a
</h1>
<div class="site-description">
<h3>
<?php echo html_entity_decode(get_bloginfo('description')); ?>
</h3>
</div>`
So instead of the h1 tag there, I would like an image that will allow the user to return to the homepage. Also would I need to save the image in a specific folder ?
Please help and thank you in advance !
try this
<img src="<?php bloginfo('template_directory'); ?>/images/logo.jpg" />
<div class="site-description">
<h3>
<?php echo html_entity_decode(get_bloginfo('description')); ?>
</h3>
</div>
assuming that image is in the images folder of template directory with file name logo.jpg
Use
<a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?>
<img src="image.jpg" width="32" height="32">
</a>
instead of
<h1>
<a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a
</h1>
Working well for me
See the image http://i.stack.imgur.com/Vs23W.jpg

PHP Include Directory

I am calling socialmedia.php from every page on my website to display a little "Social Media" div where people can visit my social media pages.
I am calling this using <?php include './socialmedia.php' ?> or <?php include './socialmedia.php' ?> depending on what directory I am in.
In my socialmedia.php file I have the following code.
<a href="http://twitter.com/kinghenryharris" target="_blank">
<img class="socialMedia" src="../images/twitter_logo.png" alt="Twitter" width="40px" height="40px"></br>
</a>
<a href="http://facebook.com/kinghenryharris" target="_blank">
<img class="socialMedia" src="../images/facebook_logo.png" alt="Facebook" width="40px" height="40px"></br>
</a>
<a href="http://youtube.com/mrgorillalogic" target="_blank">
<img class="socialMedia" src="../images/youtube_logo.png" alt="Youtube" width="40px" height="40px"></br>
</a>
Is it bad practice if I am in the home directory to do ../images/youtube_logo.png
When calling it from www.example.com/page.php does it matter that I am going up two directories with ../images/youtube_logo.png`
It seems to work but I am wondering if this is wrong or I should change it so if I am in the home directory do ./images/youtube_logo.png or should I just leave it the same?
-Henry

Categories