I'm getting started using Kohana framework. How do I properly link images? I'm linking images using the usual way:
<img src="../../resources/images/img01.jpg" />
I'm using dreamweaver, and I can see that the link is correct. Since I can see an image in the preview:
The link is still the same when I reference the image based on the controller.
Best way to use full (base)paths:
<img src="<?php echo url::base() ?>resources/images/img01.jpg" />
or:
<img src="<?php echo url::site('resources/images/img01.jpg') ?>" />
You need to use absolute links. Either use html::image(), or prefix your image with url::base(), or use url::site(). There's lots of options, read the documentation.
Related
I am trying to create an image gallery on my real estate website that displays only the images associated with the property selected. I have the following code that allows me to bring up the images associated with the property. My issue now is trying to create an image gallery from this. Any ideas on how to do this? I am using Bootstrap 2.3.2 to build the site.
<?php
$path = "../uploads";
foreach (glob("$path/{$_SESSION['propertyid']}*") as $filename):
?>
<img src="<?php echo $path ?>/<?php echo $filename ?>" alt="photo" width="250" height="250" border="0" /><br><br>
<?php endforeach ?>
I would comment with this question and then answer this but I must have 50 rep to comment.
My question is why are you still using 2.3.2. Why not upgrade to 3.2? That is just pure curiosity. Regardless of the answer, I have had to do this before. I am not proficent with entering code correctly on stackoverflow yet so here is a pastebin link. BTW, I had to go digging through an old pastebin account for this.
http://pastebin.com/kPA6Vq0g
So,
My images are located in wp-content/themes/mytheme/images
Originally, when i converted my site from html/css the path looked like this:
<img src="images/myimage.png" alt="some text" />
That did not work and I have now tried two diffrent solutions:
<img src='<?php get_template_directory_uri(); ?>/images/myimage.png'>
and
<img src="<?php bloginfo(); ?>images/myimage.png">
Have i missed something? I am new to wordpress an php and would appreciate some help. Thanks!
You almost had it. You left off echo.
http://codex.wordpress.org/Function_Reference/get_template_directory_uri
Output the URI
<?php echo get_template_directory_uri(); ?>
The full result is:
<img src='<?php echo get_template_directory_uri(); ?>/images/myimage.png'>
I recommend you use Drupal if you haven't gotten too far with WP already. :)
Try
get_stylesheet_directory(). '/images';
/images/myimage.png">
This will return the images directory path in the currently selected theme, even if it's a child theme.
Function Reference/get stylesheet directory
I'm building my first WP theme. My images are linked this way:
<img src="<?php bloginfo('wp-content/themes/SRPrint'); ?>images/freephone.png" />
Obviously theme folder called SRPrint and inside it there is an images folder.
Can't understand why images do not show up? I don't know any php so I asume problem is in php code? Images specified through style.css show up ok.
Please help.
Link to test site http://www.designstest.co.uk/
you must use <?php bloginfo('template_directory'); ?>/images/freephone.png to get the images in the current theme.
See: bloginfo
<img src="<?php bloginfo('template_url'); ?>/images/logo.jpg" alt="<?php bloginfo('name'); ?>">
Change all image to src="
<?php echo get_template_directory_uri();?>
/images/picname.jpg"
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" />
I've been able to put some code together and get a QR code to display on my site. Now I'm attempting to get the QR Code to open a larger version inside colorbox. This is the code I've got so far:
<a href="<?php echo $????; ?>" title="<?php echo $heading_title; ?>"
class="colorbox" rel="colorbox">
<img src="http://chart.apis.google.com/chart?chs=250x250&cht=qr&chld=L&chl=
<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; echo $url; ?>"
alt="Product QR Code" width="80" height="80" style="float: right" /></a>
All the code for colorbox is on this page already as I have products that use this very function. The original code said echo $popup but when I use that it shows me the main product image so that's no good. What I can't figure out is what to do with echo in the href section so it calls the image again in the pop-up box but in a larger size?
I've tried using the same url as with the img src but it only returns garbage characters in the pop-up box and doesn't know to turn it into an image instead.
Thanks for your time!
When you assign colorbox, set the photo property to true. Example:
$('a.example').colorbox({photo:true});
Colorbox normally uses a regex to determine if a link is pointing to an image or not, but the URL you are using isn't going to pass that regex.