My image didn't call, with the current path. How to fix it?
The folder data in out of folder application.
I'm using a framework Codeigniter with Bootstrap.
<center>
<a href="../../data/images/buying.png" data-fancybox="group" data-caption="How to Buying in Store">
<img class="img-flu rounded mb-4" src="../../data/images/buying.png" alt="" >
</center>
First, you need to set up this on application->config->config.php before using the base_url().
$config['base_url'] = 'http://localhost:8000/sitename';
In view
<center>
<a href="<?php echo base_url() ?>data/images/buying.png" data-fancybox="group" data-caption="How to Buying in Store">
<img class="img-flu rounded mb-4" src="<?php echo base_url() ?>data/images/buying.png" alt="" >
</center>
For more info about the proper setup or uses of base_url()
How to set proper codeigniter base url?
Related
I am using codeigniter framework in my web development and passing the value of image id using php code such below
<a href="<?php echo base_url('account/gallery/view'); ?>?id=<?php echo $imageDetail['imageId']; ?>">
<img src="" />
</a>
and getting the value at controller with this code $imageId = $this->input->get('id');
With the get method I used, it will display the url like this :
http://my-domain-name/account/gallery/view?id=1
But I want to display the url like this :
http://my-domain-name/account/gallery/1
So what I did is setting in the router with this code but it's not working.
$route['account/gallery/(:num)'] = 'default/Gallery_controller/view/$1';
My web still able to show the template of the web if I type http://my-domain-name/account/gallery/1 but display error in the field that I fetch from database because unable to get the imageId
use Regex instead of :num in route.php
$route['account/gallery/([0-9]+)'] = 'default/Gallery_controller/view/$1';
And in your template file:
<a href="<?php echo base_url('account/gallery/'.$imageDetail['imageId']); ?>">
<img src="" />
</a>
Then you can access directly in your gallary controller in view function $id.
eg:
class Gallery extends MY_Controller {
public function view($id){
// Your Image ID = $id;
}
}
Set this url http://my-domain-name/account/gallery/1 proper in href
<a href="<?php echo site_url('account/gallery/view'.$imageDetail['imageId']); ?>">
<img src="" />
</a>
Replace
<a href="<?php echo base_url('account/gallery/view'); ?>?id=<?php echo $imageDetail['imageId']; ?>">
with
<a href="<?php echo base_url();?>account/gallery/view/<?php echo $imageDetail['imageId']; ?>">
Check your config.php
$config['enable_query_strings'] = true;
to
$config['enable_query_strings'] = false;
In this try this (:any)
$route['account/gallery/(:any)'] = 'default/gallery_controller/view/$1';
Or
$route['account/gallery/view?(:any)'] = 'default/gallery_controller/view/$1';
In the routes lower case
This code is make your url like http://domain-name/account/gallery/1
Try this:
<a href="<?php echo base_url();?>account/gallery/view/<?php echo $imageDetail['imageId'];?>">
<img src="" />
</a>
I wrote a code which is retrive image paths and display on the website in bootstrap grid style.But it does not showing the image. Code is working fine, Please help me. here is my code
<div class="row">
<?while ($row = mysql_fetch_assoc($query)) {?>
<div class = "col-md-3">
<?php echo $row['keywords'];?>
<?php $imagePath = $row['video_url'];?>
<?php echo $imagePath;?>
<div id="video_thumbnail">
<a href="#" class="thumbnail">
<?php echo '<img src="' . $imagePath . '">'; ?>
<img src="<?php echo file_dir . '/' . $imagePath; ?>" height="100" width="100"/>
</a>
</div>
</div>
<?php } ?>
</div>
unless file_dir is a constant using DEFINE, I suspect it's because you didn't put a $ in front of it $file_dir
You are also displaying two files. One with the file path and one without.
Chances are, the mysql query is returning a path which is not linked ....
ie <image src="myImage.jpg" /> is not the same as <image src="images/myImage.jpg" />
As #pmahomme said, right click the element and check the pat and if need be add the additional requirements
I am trying to develop this blog http://www.racecarwow.com . I have used youtube video thumbnail for post thumbnail . In single post , there is a facebook share button. When i click on it, it is not showing the post thumbnail image. it only show a fix image for all post thumbnail during share. I have used the following code for post thumbnil
<a class="thumbnail" href="<?php the_permalink(); ?>">
<img class="img-responsive" src="http://img.youtube.com/vi/<?php echo $youtube_code; ?>/hqdefault.jpg" alt="<?php the_title()?>" />
</a>
Here $youtube_code is coming from custom field. I have also try this following way
<a class="thumbnail" href="<?php the_permalink(); ?>">
<?php if($post_img_src){?>
<img src="<?php echo $post_img_src[0] ?>" alt="<?php the_title();?>" class="img-responsive">
<?php } else{?>
<img class="img-responsive" src="http://img.youtube.com/vi/<?php echo $youtube_code; ?>/hqdefault.jpg" alt="<?php the_title()?>" />
<?php }?>
</a>
And i have used the following code for share post
<a class="btn btn-block btn-social btn-facebook" href="https://www.facebook.com/sharer.php?u=<?php echo urlencode(get_permalink($post->ID)); ?>&t=<?php echo urlencode($post->post_title); ?>"target="_blank">
<i class="fa fa-facebook"></i> Share on facebook
</a>
Please tell me the solution.
You need to put your thumbnail image in a meta tag that Facebook can read for each post:
<meta property="og:image" content="http://img.youtube.com/vi/<?php echo $youtube_code; ?>/hqdefault.jpg" />
I think you have a plugin that has the Facebook meta tags, you might need to edit the plugin in order for your custom thumbnails to show with the other meta info.
You can debug your website on Facebook here https://developers.facebook.com/tools/debug
I have built a site for someone else who will be updating it via a CMS (CushyCMS). They wanted a lightbox gallery included. I want to be able to allow them to upload a new image and for that image url to be copied into the a tag so lightbox works.
So far I am able to do that, but the client has to ensure the file names and format are exactly the same as what I have set them to in the php code. Is there a way to get the img url from the img tag (possibly identifying it using an id attribute) and put it directly into the tag?
Heres what I have so far:
<?php
$src1 = "images/test1.jpg";
$src2 = "images/test2.jpg";
?>
<a href="<?php echo $src1?>" data-lightbox="group-1">
<img class="cushycms profile" name="image1" id="slideshow_image" src="images/test1.jpg"/></a>
<a href="<?php echo $src2?>" data-lightbox="group-1">
<img class="cushycms profile" id="slideshow_image" src="images/test2.jpg"/></a>
Many thanks!
You can do it with jQuery:
<a data-lightbox="group-1">
<img name="image1" src="images/test1.jpg" />
</a>
<script>
var img = $('img[name="image1"]');
var imgSrc = img.attr('src');
img.parent().attr('href', imgSrc);
</script>
If you have multiple images and want to automate this you can use the map function:
<a data-lightbox="group-1">
<img name="image1" src="images/test1.jpg" class="slideshow" />
</a>
<a data-lightbox="group-1">
<img name="image2" src="images/test2.jpg" class="slideshow" />
</a>
<a data-lightbox="group-1">
<img name="image3" src="images/test3.jpg" class="slideshow" />
</a>
<script>
$(".slideshow").map(function() {
$(this).parent().attr('href', this.src);
});
</script>
Assuming you use jQuery somewhere there, you could/should use a lightbox plugin, like this one here:
http://www.jacklmoore.com/colorbox/
Using the xamples there, you would then use:
(http://www.jacklmoore.com/colorbox/example1/)
$('a.gallery').colorbox({rel:'group-1'});
which would result in a lighbox gallery showing on "click" on any anchor with class "gallery" while the gallery would show all the elements pointed by "href" from all anchors of that have class="group-1" (so each anchor would be
although you have to include some files for jquery and the lightbox plugin, I think it will make your life much easier in the end.
Also not sure what your php level is, but the example code you have there asks for:
<?php
$images = array(
'images/test1.jpg',
'images/test2.jpg'
);
?>
<?php foreach($images as $i => $url): ?>
<a href="<?php echo $url?>" data-lightbox="group-1">
<img class="cushycms profile" name="image<?php echo $i+1 ?>" id="slideshow_image" src="<?php echo $url ?>"/>
</a>
<?php endforeach; ?>
Just in case you got more images there.
I am using a PHP Framework for the first time to get away from writing spaghetti code and so far it is wonderful. I am using Code Igniter and have a base Controller named "Dashboard.php" that loads fine and looks perfect.
When attempting to create some organization, I placed my "Devices.php" into a "Controllers/Devices" sub-folder, then accessed it at "http://domain.com/devices/devices" which loads the text, but the images/css/etc. are missing.
The content of the "Devices" controller is exactly the same as my "Dashboard" so I am not understanding why only the text loads. If I move the "devices.php" file into the root Controllers directory, there are no problems.
class Devices extends CI_Controller
{
public function index()
{
$data['page_title'] = 'Device Portal';
$this->load->view('meta');
$this->load->view('sidebar');
$this->load->view('userbar');
$this->load->view('header');
$this->load->view('devices/content');
$this->load->view('footer');
}
}
Here is the "Sidebar.php" View...
<!-- Left side content -->
<div id="leftSide">
<div class="logo"><img src="assets/images/logo.png" alt="" /></div>
<div class="sidebarSep mt0"></div>
<!-- Search widget -->
<form action="" class="sidebarSearch">
<input type="text" name="search" placeholder="search..." id="ac" />
<input type="submit" value="" />
</form>
<div class="sidebarSep"></div>
<!-- General balance widget -->
<div class="genBalance">
<a href="#" title="" class="amount">
<span>General balance:</span>
<span class="balanceAmount">$10,900.36</span>
</a>
<a href="#" title="" class="amChanges">
<strong class="sPositive">+0.6%</strong>
</a>
</div>
You need to avoid using relative paths when linking to images/css/etc in your views.
As an example, when you use assets/images/logo.png (relative path) from the page http://domain.com/devices/devices, the browser looks for http://domain.com/devices/assets/images/logo.png
Using the same image path with the page http://domain.com/devices the browser will look for http://domain.com/assets/images/logo.png instead.
When specifying urls to pages, images, etc within your domain, use the URL helper functions to automatically format your urls.
You want to avoid writing urls like this:
<script type="text/javascript" src="./assets/js/jquery.js"></script>
<img src="assets/images/logo.png" alt="" />
And instead generate your urls like this:
<script type="text/javascript" src="<?php echo base_url('assets/jquery.js'); ?>"></script>
<img src="<?php echo base_url('assets/images/logo.png'); ?>" alt="" />
Which will output:
<script type="text/javascript" src="http://domain.com/assets/js/jquery.js"></script>
<img src="http://domain.com/assets/images/logo.png" alt="" />
In Codeigniter use base_url() function to print assets.
<img src="<?php echo base_url('assets/images/logo.png');?>" alt="" />
This function automatically generate domain before the url.