Welcome Guest, Not a member yet? Register   Sign In
image plugin
#1

[eluser]steel_slasher[/eluser]
this is my first contribution the the CI development/expansion basically i wanted to load images in HTML without all the slashes and speech marks so i thought i would make a helper at first but realised i would only need one function so i moved to a plug-in.

Basically you load the plug-in like so:
Code:
$this->load->plugin('image');

and to output the image HTML you use this function:
Code:
$file = "myimage.gif";
$path = "/images";
echo image($file, $path);
//outputs <img url="/images/myimage.gif" />

a default path can be set in the plugin file itself (this bit needs testing at the min):
Code:
&lt;?php

function image($name, $path="/system/images/")
    {
        foreach ($name as $file){
            echo "<img url=\"". $path. $file. "\" />";
        }
    }

?&gt;
to the best of my knowledge of php functions you can set the default path by changing
Code:
$path="/system/images/"
to
Code:
$path="/whatever/folder/youwant/"
a trailing and leading slash MUST BE USED!

if you want to use the default path just call the function with the file variable
Code:
$file = "myimage.gif";
echo image($file);

if you want to load several images then an array can be used
Code:
$files= array("file1.gif", "file2.gif", "file3.gif");
echoimage($files);

here is the source:
Code:
&lt;?php

function image($name, $path="/system/images/")
    {
        foreach ($name as $file){
            return "<img url=\"". $path. $file. "\" />";
        }
    }

?&gt;

if there are any problems please say and also i am planning to expand to cover other media types like flash but then it would become a helper.

Download it here:
http://sitecrackerz.wordpress.com/2008/0...-app-ever/
#2

[eluser]Pascal Kriete[/eluser]
Sounds very similar to the img() function of the html helper, but thanks for sharing nonetheless.

Btw, your link has one too many 'my-first...'.
#3

[eluser]steel_slasher[/eluser]
[quote author="inparo" date="1207868756"]Sounds very similar to the img() function of the html helper, but thanks for sharing nonetheless.

Btw, your link has one too many 'my-first...'.[/quote]
i couldnt find that function and damn wordpress for giving me a stupid link




Theme © iAndrew 2016 - Forum software by © MyBB