Jump to content

construct image path for external script


bluehat09

Recommended Posts

@rocky or @tomerg3 Please help. Thanks.

First of all, many thanks for PrestaShop. My preferred business and e commerce CMS.

 

I'm trying to do a WP plugin that will show PrestaShop products randomly from the whole database and from one specified category.

 

I need to construct the image path for a product having the product id only.

 

All I ask is a SQL query that will help me to construct the right path to the right image for the right product.

I know the default path is img/p/product_id/image_id/product_idimage_id-home.jpg and that's all I need.

E.g.: \img\p\1\5\15-home.jpg

For the purpose of simplicity I will ignore the colors and the language.

My problem is how to get the image_id

I suppose is all about left join some tables. Any suggestion is welcomed.

Thanks for help.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

Thanks cd2500 for your suggestion. For me, the wiki is useless.

 

What I'm trying to do is to pull out the images.

I figure out that complicate SQL and even I constructed the path.

 

The problem come from using an htacess file to rewrite the path for images.

 

Now, the real problem is the image will not show the first time but second time.

It looks like is cached somehow or I have access denied somewhere.

 

I randomly select 3 products from database. I first look if the files exist in their physical location and they exist.

When I'm trying to display them in my WP, the images are not there.

Strange isn't it?

 


$image_path = $image_folder . '/' . $row['id_product'].'-' . $row['id_image']. '-' . $image_size . '.jpg';
$image_path_no_image = 'images/no_image.jpg';
if (url_validate($image_path)){
echo '<img src="'.$image_path.'" alt="'.$row['name'].'" /></a><br />';
}else{
echo '<img src="'.$image_path_no_image.'" alt="No image" /></a><br />';
}

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...