Welcome Guest, Not a member yet? Register   Sign In
IE not fetching images
#1

[eluser]iFadey[/eluser]
Recently I did a project using CI. It's almost completed. While testing it in different browsers I found that IE is not loading images when a page's URL contain controller method name. Example:

Code:
http://localhost/my_project/controller/method
(not fetching images)

But if any page that's displayed without method name fetch images. Example

Code:
http://localhost/my_project/controller
(works fine)

When I checked the image paths of page when opened in IE, it looks like this:
Code:
http://localhost/my_project/controller/method/images/subfolder/img.jpg

Now obviously this is wrong because the correct path is:
Code:
http://localhost/my_project/controller/images/subfolder/img.jpg

The weird thing is that it's happening only in IE Sad
I don't understand htaccess syntax that much. I am new to it so maybe I am doing some mistake there. Here's my .htaccess file:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|styles|scripts|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

Also all of my images are in sub folders present in "images" folder which is in root directory
#2

[eluser]pistolPete[/eluser]
Try using absolute image paths in your views.
#3

[eluser]iFadey[/eluser]
I am doing it this way:

Code:
<base href="<?php echo base_url(); ?>" />
<img src="images/subfolder/img.jpg" alt="My Image" />

So I think this makes absolute path, not relative Smile
#4

[eluser]iFadey[/eluser]
I got the solution. When I used img() from html helper, now it works fine in IE as well Big Grin
But still I am wondering that the previous code works in other browsers then why not in IE?
#5

[eluser]InsiteFX[/eluser]
Try this from the users guide load the html helper.

Code:
$this->load->helper('html');

$image_properties = array(
          'src' => 'images/picture.jpg',
          'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
          'class' => 'post_images',
          'width' => '200',
          'height' => '200',
          'title' => 'That was quite a night',
          'rel' => 'lightbox',
);

img($image_properties);

This will put the whole path in it for you.

Enjoy
InsiteFX
#6

[eluser]iFadey[/eluser]
Exactly! This is what I did now. It works fine Smile
Thanks for the help




Theme © iAndrew 2016 - Forum software by © MyBB