Correct Image Path Of Product Images

I get the image names by a query (below). But how can I ensure/find the images paths of product images? I know images are saved under the folder “\images\detailed\2” after 1000 images uploaded under the path “\images\detailed\1”. (defined in config.local.php) which directory did images saved? under “1” or “2”? How to know this?



//images db
$data= db_get_array("SELECT ?:images.image_path, ?:images_links.type FROM ?:images ".
"LEFT JOIN ?:images_links ON ?:images_links.detailed_id = ?:images.image_id ".
"WHERE ?:images_links.object_id = ?s", $product['product_id']);

<br />
//images db<br />
   $data= db_get_array("SELECT ?:images.image_path, ?:images_links.type FROM ?:images ".<br />
		  "LEFT JOIN ?:images_links ON ?:images_links.detailed_id = ?:images.image_id ".<br />
		  "WHERE ?:images_links.object_id = ?s", $product['product_id']);<br />

```<br />
<br />
I found the way how to to get image paths. I can get the URL of main image of product, but I couldn't find what code should I write for getting additional image urls of the product. Here is the code part.??? <img src="upload://n4syhXZrRhsStKvmS4jT3Mp2S3k.png" class="bbc_emoticon" alt=":("><br />
<br />
<br />
```php
<br />
foreach ($data as $k => $v) {<br />
<br />
   $images = fn_get_image_pairs($product['product_id'], 'product', $v['type'], false, true, $lang_code);<br />
<br />
   if ($v['type'] == 'M') {<br />
			$data[$k]['image_url'] = $images['detailed']['image_path'];<br />
   }<br />
  <br />
   if ($v['type'] == 'A') {<br />
			$data[$k]['image_url] = // ??????????????????<br />
  <br />
   }<br />
<br />
fn_print_r($data[$k]);<br />
<br />
}<br />
<br />

The path to any image_id (detailed or image/thumb) is done as:


$sub_dir = floor($image_data['image_id'] / MAX_FILES_IN_DIR);
$path = "images/detailed/$sub_dir/$image_data['image_path'];


Substitute 'detailed' for the image directory you're interested in. I.e. Thumbnails. But note that thumbnails are also indexed by width and height.

And if you're creating the image and want to know what $sub_dir to use you would:

$sub_dir = floor(db_get_next_auto_increment_id('images') / MAX_FILES_IN_DIR);

and $sub_dir would be the sub_dir of the next image to be created. But you only need this part if you're importing your own imagery.

Hi,



I was trying to get a full image url of any product that I click.



I came to read somewhere that we can get the product image url with this code below.



$product['main_pair']['detailed']['http_image_path'];



I tried but it returns null value. Similarly I tried to get the product id using $product['product_id']. It still gives null.



I m not sure about the $product variable in my ajax request code.



Can anyone let me know more about the $product variable and why I couldn't use it in my custom addon ajax code.?



Do I've to initialize $product variable anywhere in my addon view page?

Not sure what are do you use (store-front or admin panel). But try the following code



$product = fn_get_product_data($_REQUEST['product_id'], $auth, CART_LANGUAGE, '', true, true, true, true, fn_is_preview_action($auth, $_REQUEST));
fn_gather_additional_product_data($product, true, true);
Registry::get('view')->assign('product', $product);