Jump to content

image path


adller99

Recommended Posts

I made this simple code to retrieve all images from products or categories, it may help you on your question:

function getProductImage($id_image){
$base_url = url();
$base_url .= 'img/p/';
$id_image_array = str_split($id_image);

for($i=0;$i<count($id_image_array);$i++){ 
   $base_url .= $id_image_array[$i].'/'; 
} 

$base_url .= $id_image.'-large_default.jpg';

return $base_url;
}

function getCategoryImage($id_image){
$base_url = url();
$base_url .= 'img/c/';

$base_url .= $id_image.'-medium_default.jpg';

return $base_url;
}

function url(){
$base_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

    if(isset($_SERVER['HTTPS'])){
        $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
    }
    else{
        $protocol = 'http';
    }


    $base_url = explode('?', $base_url);
    return $base_url[0];
}
Edited by Darknoe (see edit history)
Link to comment
Share on other sites

 

I made this simple code to retrieve all images from products or categories, it may help you on your question:

function getProductImage($id_image){
$base_url = url();
$base_url .= 'img/p/';
$id_image_array = str_split($id_image);

for($i=0;$i<count($id_image_array);$i++){ 
   $base_url .= $id_image_array[$i].'/'; 
} 

$base_url .= $id_image.'-large_default.jpg';

return $base_url;
}

function getCategoryImage($id_image){
$base_url = url();
$base_url .= 'img/c/';

$base_url .= $id_image.'-medium_default.jpg';

return $base_url;
}

function url(){
$base_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

    if(isset($_SERVER['HTTPS'])){
        $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
    }
    else{
        $protocol = 'http';
    }


    $base_url = explode('?', $base_url);
    return $base_url[0];
}

well, it doesn't. Cause I dont see what the input + output is. Can you tell me whether is gonna creating folders like this 

id_image = 235

 

so it'll create \img\p\23\5 ?

 

thanks

 

Link to comment
Share on other sites

well, it doesn't. Cause I dont see what the input + output is. Can you tell me whether is gonna creating folders like this 

id_image = 235

 

so it'll create \img\p\23\5 ?

 

thanks

 

If you follow the method flow you will get this:

 

$img_src = geProductImage(235);

echo $img_src; --> www.yourbasepath.com/img/p/2/3/5/235-large_default.jpg

 

So your new folder will be img/p/2/3/5/

Edited by Darknoe (see edit history)
Link to comment
Share on other sites

If you follow the method flow you will get this:

 

$img_src = geProductImage(235);

echo $img_src; --> www.yourbasepath.com/img/p/2/3/5/235-large_default.jpg

 

So your new folder will be img/p/2/3/5/

 

I guess, you are pretty possitive about it, right? ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...