how to put <img> tag in header.php in Wordpress - image

i have used the following code but it didnt work
/images/ncr.jpg" alt="ncr.com" />
I have pur my image in the images folder of twentyeleven child theme
can anyone help
Thanks in advance..

The theme folder URL can be found at /wp-content/themes/twentyeleven.
Your header file is actually included at the root level, and as such relative paths won't work.
WordPress provides a function to access your current theme's directory, and as a result you should use this code:
<img src="<?php echo get_template_directory_uri(); ?>/images/ncr.jpg" alt='ncr.com'>

Related

How to add background image at the login page?

so there is this project iam working on..now i want to add a background image at the login page....i have tried to upload the photo on the public/background folder...then in the css file i have created the directory but so far no changes!!
now my project look like below ..i have uploaded an image named backgroung.jpg on background folder but also in public/background and /public_html/vendors/gauge.js/assets then at my css file html {
background_image:url('public/background/background.jpg')} so far no changes
accountant
app
background
bootstrap
build
config
css
customer
database
employee
garage
garragelogo
general_setting
img
js
.
.
.
html {
background_image:url('public/background/background.jpg')}
i expected a lot i guess help please ......
You need to specify your path relatively like this ../../../public/background/background.jpg which ../ is a backward directory
or you can set your background in your html tag like this
<html style="background: {{ asset('background/background.jpg') }}">
hope it helps
Use this code block for setting background image on any page.
<div class="classToDefineBackgroundSetCss" style="background-image: url('{{asset('assets/bg-slider/bg-slider1.jpg')}}');">
<form>
<!-- LOGIN FORM -->
</form>
</div>

Image isn't visible in my site

I've just added a simple code (<img src="images/2.jpg"/>) in my WordPress website. But it's not working. Check it out
Please help me to solve the issue.
Try add leading slash to your image path to start at the root directory instead of your current directory where your code is located:
<img src="/images/2.jpg"/>
most likely the path is incorrect. images is not immediate directory to your current page directory.
usually in wordpress images are in wp-content/uploads/2017/05/%some_image.jpg%
you are using <img src="path"/> you can solve this issue by adding the url of the image like ‪C:\Users\Hitesh Kumar\Desktop\xyz.jpg.
but i know that you are using wordpress so you can add the image by its url like <img src="www.site_name/image.jpg"/>
hope it will help
Need to add this code (<?php echo get_template_directory_uri();?>) to make it dynamic.

How to display images using codeigniter

am trying to display the images of my products in a shopping cart and this is the code am using to do that...
<img src=" <?php echo 'image/'. $product['picture']?>" /><br />
but the images do not show. I have stored the images in a folder called image outside applications.
You can use base_url to get full path without index.php.
Hope you images folder exist in project root folder.
<img src="<?php echo base_url('image/'. $product['picture']);?>" />

How do I reference a local file properly?

I'm running Wordpress on WAMP right now and I'm trying to figure out how to correctly reference an image that i'm using in my header for all my pages.
If I write this:
<img src="wp-content/themes/my-theme/images/SSBlogoALPHA.png">
the logo shows up on the WP homepage, but not on any subsequent pages.
If I write
<img src="../wp-content/themes/my-theme/images/SSBlogoALPHA.png">
the logo shows up on all subsequent pages, but not the homepage.
to be honest I don't know what the "../" does or where my root folder is supposed to be when writing a directory path but these are the ways that i've seen other people do this. Any ideas? Thanks!
you can get the images by following way
<img src="<?php bloginfo('template_directory'); ?>/images/SSBlogoALPHA.png" alt=""/>

where should I add external file to view in CI

I'm trying to make view page in CodeIgniter,So I create it and in Controller it loads complete.
but when I add images and jQuery to it,they will not be loaded.
I made sub folder in view folder by name of Files and add to view for e.g like that
img src="Files/01.jpg" but it will not be shown.
where should I place them?
I usually make a folder called files in the main directory (where system and application reside), and then link to them using base_url().
In your case, this would become
<img src="<?= base_url(); ?>/files/01.jpg" />
Hope that helps.
When your view loads, the file paths will be relative to the directory the CodeIgniter index.php file is located in. If this is also the root directory of your site, you can refer to it in this way: <img src="/Files/01.jpg" />

Resources