CodeIgniter Forums
Images Library - intercept "/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: Images Library - intercept "/images/" (/showthread.php?tid=26566)



Images Library - intercept "/images/" - El Forum - 01-17-2010

[eluser]Innovatics[/eluser]
Hey guys,

I'm currently developing an Images Library. I want to resize Images dynamically on calling

http://localhost/<b>images</b>/image.jpg

I don't want to use a controller, I would like to use a Library by intercepting the "/images" path - simply because I only want to copy this file from project to project.

That works fine if I include the library into autoload, but if there is no controller or function, I get 404, without calling the Images constructor. Do have an idea without changing other files?

Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Images {

    function Images()
    {
        $CI =& get_instance();

        if ($CI->uri->segment(1) == 'images')
            die('Show Picture');
    }

}


Regards,
Christian


Images Library - intercept "/images/" - El Forum - 01-17-2010

[eluser]Ian Jones[/eluser]
Have you investigated using routes?

You can intercept any uri call and direct it to a custom controller