![]() |
Can img tag be used in a view? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: Can img tag be used in a view? (/showthread.php?tid=61458) |
Can img tag be used in a view? - cupboy - 04-16-2015 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? RE: Can img tag be used in a view? - Rufnex - 04-16-2015 How does your template code looks like and where are your images located. e.g. you ar in the webroot /assets/images/ then you have to write <img src="/assets/images/your_image.png" /> in your template. RE: Can img tag be used in a view? - RobertSF - 04-16-2015 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. Code: <img src = "assets/your_picture.jpg"> You can add other tags, of course, like alt, width, and height. RE: Can img tag be used in a view? - ivantcholakov - 04-16-2015 Code: <img src="<?php echo base_url('assets/img/your_picture.jpg'); ?>" /> RE: Can img tag be used in a view? - colonelclick - 04-17-2015 Use absolute URL to you image. Start the url with / RE: Can img tag be used in a view? - freddy - 06-05-2015 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 Code: <?php 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 |