Welcome Guest, Not a member yet? Register   Sign In
Can img tag be used in a view?

I thought I already posted this thread but I can't find it now, so it may be a duplicate.

So anyway I will retype all this: I converted an html file to a view file (.php) and now the images don't show up. It works fine outside of CI, so does CI not support images this way and if so how do I insert images?

How does your template code looks like and where are your images located.

e.g. you ar in the webroot


then you have to write

<img src="/assets/images/your_image.png" />

in your template.


Yes, you should be able to use any valid HTML in a view file. Is it displaying the broken picture icon? The problem may be the path.

Try creating a folder called "assets" (or whatever) in your CI folder, not in your application folder but next to your application folder. So when you look in your CI folder, you will see application, assets, and system folders. Then put your images in the assets folder, and in your view, refer to them like this.

<img src = "assets/your_picture.jpg">

You can add other tags, of course, like alt, width, and height.
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!

(This post was last modified: 04-16-2015, 03:26 PM by ivantcholakov.)

<img src="<?php echo base_url('assets/img/your_picture.jpg'); ?>" />

Use absolute URL to you image. Start the url with /

is it solved or not, if stil figure out it hope this help some one else who came up with this issue

here is simple

//define your path as variable
$image_path = base_url()."image/barang";
if ($row->gambar1=='')
//show image without database
echo " <img class='list-group-image' src='$image_path/noimage.png' />";
//show image with database
echo " <img class='zoom_01 group list-group-image' src='$image_path/$row->gambar1' alt=''  data-zoom-image='$image_path/$row->gambar1'/>";

remember you cannot show image came from datase like this
<img src="<?php echo base_url()/uploads/artikel/1.png?>">

You should define path, Thanks

Freddy Sidauruk

Theme © iAndrew 2016 - Forum software by © MyBB