Welcome Guest, Not a member yet? Register   Sign In
JavaScript link to images
#1

[eluser]JohnDoerther[/eluser]
Hi guys,

I just installed the lightbox plugin for Jquery which works great, the only thing that is still not working are the images (next button, loading image, ...).

CI is linking the images to /index.php/back/catalog/images/lightbox-btn-close.gif, but the actual images are in the root directory if my CI installation.

Is there an easy way in CI to say for example:

"Redirect all requests for /index.php/back/catalog/images/ to mywebsite.com/images" ?

Thanks in advance!


EDIT: so basically I want to define rules so that URL's for images are absolute paths and not links to controllers and functions..
I tried a redirect like

Code:
$route['back/catalog/images/:any'] = base_url(). "gfx/images/" . $1;

but this does not seem to work..
#2

[eluser]pickupman[/eluser]
The image locations are relative to the css document, so you may have to edit the lightbox.css script to work up the tree to get to the image
Code:
.left-arrow{
background: url(../gfx/images/lightbox/left-arrow.gif);
}

This code goes up one folder from the css folder and then into the images/lightbox folder. Routes would only work for actual CI urls not file links. You would need to use mod_rewrite in .htaccess to create a rule like that.
#3

[eluser]haydenk[/eluser]
http://codeigniter.com/wiki/mod_rewrite/

If you use the new htaccess method, this i taken care of for you.

Specifically, this part.
Code:
#Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
So, if an ACTUAL file exists at the URL you enter, then it will go the actual file, otherwise it gets routed to the index.php and processed through the controllers.




Theme © iAndrew 2016 - Forum software by © MyBB