All the Images of the website doesn't appear.
If I access the default url, specified in config file, under the base_url, all the images have shown.
But when I access this url (127.0.0.1/dcm/Controller/Index), not even a single image is retrieved.
I think it's a path problem, but I can't figure it out properly.
Here's my root folder structure (I'll try to make it understandable):
css
dcmapp -> Here I have my views
dcmsys
htmlconstants -> Here are my header and footer, common in all pages
Images -> Here are all the website images
Scripts
For example, in my header.php in htmlconstants folder, I have this code, for example:
<img src="<?php base_url() ?>Images/fbic.png">
<img src="Images/phone.png">
<img src="Images/email.png">
As you can see in code, I'm trying to use a base_url function to see if I can get the full path till the image, with no success.
In my Views, the same thing.
instead of
<img src="<?php base_url() ?>Images/fbic.png">
try this:
<img src="<?php echo base_url(); ?>Images/fbic.png"></img>
Related
Migrated my joomla site to WP. The images were in a folder named 'asets' in joomla site. I copied the dir to wp and images work fine while url structure is raw.
But if I change the url permalink, the link to images also change.
like
sitename/?p=123 image path = sitename/asets/imagefile this works.
sitename/samplepost image path = sitename/post-name/asets/imagefile image not found
sitename/archive/123 image path = sitename/archive/asets/imagefile image not found
Please help me to solve this problem.
Just use absloute path or relative path with slash at start of path to get the root path.
I guss your HTML code look now like this:
<img src="assets/imagefile.jpg" alt="" />
So is it a relative path, the browser add the src to current url.
But if you change this to relative path from root it's will be work:
<img src="/assets/imagefile.jpg" alt="" />
Or using full absolute path:
<img src="http://example.com/assets/imagefile.jpg" alt="" />
All about HTML file paths
More important thing, in wordpress you must to work only in theme directory scope And use get_stylesheet_directory_uri() function.
Your code need to look like this:
<img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/imagefile.jpg" alt="" />
I'm creating a wordpress theme. and i want some of the images to remain static. how can i get the url behind my image source.
My Default Image URL
<img src="assets/logo/logo.jpg">
I was trying <img src="../assets/logo/logo.jpg">
Is there any function of wordpress that we can use to get the url of an image?
You need to get the full path of the theme folder too you can do it like this
<img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/logo/logo.jpg">
how can i set image url in page ?
In image you can see I have tried by three ways but it not work.
Images are located under image folder of active theme.
You have three image tags all pointing to different urls of which two appear malformed.
The middle image tag in your screenshot seems the most accurate but you may want to add a semicolon after the right paranthesis.
If all three files are supposed to refer to the same image, then replace the first and last image tags with the middle one.
Then if it still doesnt work then replace bloginfo('template_directory') with the actual location to the images relative to document root on the server but put the value in quotes. For example, if your images are in the subfolder images in folder imageset on your site, then you could use
"http://www.whatever.com/imageset/images" or "/imageset/images".
which results in the code:
<img src="<?php echo "/imageset/images"; ?>/images/banner1.jpg" alt="">
or even better:
<img src="/imageset/images/images/banner1.jpg" alt="">
Try as follows <img src="../images/banner1.jpg" alt="">
I have a main domain that users can upload images to which are then viewed in a slider so multiple images (sometimes up to 50) are loaded by the page on loading. I am trying to access the same images on a subdomain but it isn't working very well.
If I use
<img src="<? echo 'http://www.mysite.co.uk/'.$row['imageLocation']; ?>">
the images load but it is very slow
If I use
<img src="<? echo '/home/myname/public_html/mysite.co.uk/'.$row['imageLocation']; ?>">
the images aren't displayed despite the path being correct. If I use the same path for getting the images sizes (getimagesize) it returns the correct results so I'm sure the path is correct.
The images arent shown because you echo the path to the user first, but not the file itself and then the users browser loads them asynchronously. He cannot access any parent directory from mysite.co.uk only child directories.
The PHP can load them because it runs on the server itself before it is returning anything.
What you could do is using the readfile() function from PHP in an extra PHP file like getimages.php or just use the first solution, which cannot be improved in speed except you will change the image sizes, which might be your main problem here.
If you want to directly echo image file content, use this.
<img src="data:image/jpeg;base64,<?php echo base64_encode('/home/myname/public_html/mysite.co.uk/'.$row['imageLocation']); ?>" />
I am new to MAMP and I am developing a theme I designed. However I can't seem to get the images to render. I am using a clear theme I got from starkerstheme.com
When adding an image directly to the code I used:
<img src="<?= $theme ?>/images/logo.png"/>
But the image is not showing up, also I tried to add it to the media library and it's still not rendering.
This works for me:
<img src="<?php echo get_bloginfo('template_url') ?>/images/logo.png"/>
See get bloginfo() function for more info.
You can use the following code to add an image. This works for me:
<img src="<?php echo get_template_directory_uri(); ?>/images/filename.png">
<?php echo get_template_directory_uri(); ?>
as suggested gets the PARENT theme, which is OK but if you've developed a child theme (as recommended by WordPress people) you need:
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/Logo.png">
Just go to your dashboard and upload your picture in the media section, then select it you'll see the image options .. then copy it's url
<img src="your/copied/url"/>
This aslo works for me in localhost
You might need to do the full <img src="<?php echo $theme; ?>/images/logo.png"/>
Update I didn't read your question closely enough. If you're using the media library for the image, you'll need to specify the actual path to the image. You can figure this out from within the media library, but it's probably site_url/wp-content/uploads/2012/01/filename.jpg
In short, if you uploaded it in media, it wouldn't actually be in your theme.
<?php bloginfo('template_directory'); ?>/
use for internal root folder in images to place on theme on wordpress.
The forward slash is needed for the image to show
Remove the = after <?
<img src="<? $theme ?>/images/logo.png"/>
in fact, I'd probably do something like this:
<img src= <?php $theme ?> . "/images/logo.png"/>
on 2021...
Just name the image as screenshot.png [ recommended image size (currently) is 1200px wide by 900px ] and put it on theme's top-level directory (where the style.css file is )
and that's all you need to do.