CodeIgniter Forums
help displaying images - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: help displaying images (/showthread.php?tid=59531)



help displaying images - El Forum - 10-16-2013

[eluser]webdevguy32[/eluser]
I am calling an img src from:
/application/views/view_page

Here's the code I have tried:
Code:
<?php
                $image_properties = array(
                'src' => 'image/logo.gif',
                'class' => 'post_images',
                'width' => '200',
                'height' => '200',
                'rel' => 'lightbox'
                );

                echo img($image_properties);
            echo img('image/logo.gif');
echo br(5);
?>
<img src="&lt;?=base_url()?&gt;/image/logo.gif" />
<img src="&lt;?php echo site_url('/image/logo.gif'); ?&gt;" />
Here are the directory structures where I have tried placing the image = logo.gif
Code:
-application
-image / logo.gif

Code:
-application
-application / image / logo.gif

Code:
-application
-application / views / image / logo.gif
Here's my .htaccess
Code:
Options +FollowSymLinks
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteCond %{REQUEST_URI} !-l
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

None have worked, all have displayed the image stub<broken image> and when I try going to the image uri, it 404's out.

Any help is much appreciated!


help displaying images - El Forum - 10-17-2013

[eluser]webdevguy32[/eluser]
Figured it out after three hours of research. Here's the NEW .htaccess. Hopefully this will help others having the same problem.
Code:
Options +FollowSymLinks
    RewriteEngine On

# The line below is what fixed the problem. I have the image folder in root,
# at the same level as CI /application
RewriteRule ^(image)($|/) - [L]

    RewriteCond %{REQUEST_URI} !-f
    RewriteCond %{REQUEST_URI} !-d
    RewriteCond %{REQUEST_URI} !-l
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]



help displaying images - El Forum - 10-17-2013

[eluser]noideawhattotypehere[/eluser]
You didnt really need to change htaccess, seems like your base_url is configured in a wrong way. You didnt add trailing slash after it?
RewriteCond %{REQUEST_URI} !-f - wont rewrite if url is a file
RewriteCond %{REQUEST_URI} !-d - wont rewrite if url is a directory


help displaying images - El Forum - 10-17-2013

[eluser]webdevguy32[/eluser]
Thanks nodia. I didn't add a trailing slash after what? Thanks.


help displaying images - El Forum - 10-17-2013

[eluser]noideawhattotypehere[/eluser]
application>config>config.php find $config['base_url'] and check it


help displaying images - El Forum - 10-17-2013

[eluser]webdevguy32[/eluser]
I can, and have found it. But what change do you advise, or what SHOULD it be?


help displaying images - El Forum - 10-17-2013

[eluser]CroNiX[/eluser]
it should be "http://www.yoursite.com/" <-with slash at end