Jump to content

How can I easly nom the image name of a product id


pierrot10

Recommended Posts

Dear All,

 

I have to do a simple PHP script located on

/themes/mytheme/include/home.php

 

That script is called from the editorial module (.tmp)

{include_php file='themes/rivesgeneve/include/home.php'}

 

It works well.

 

The problèm, I need to display the large image of a product

<img id="categoryImage" src="img/p/12-53-large.jpg" />

 

Here is my code

<div id="image_category_home" style="border:0px;" class="align_center">
<div class="mask_cat_img"></div>
<ul id="home_diapo">
<li>
<img id="categoryImage" src="img/p/12-53-large.jpg" />
<center>Legende 1</center>
</li>
<li>
<img id="categoryImage" src="img/p/6-58-large.jpg" />
<center>Legende 2</center>
</li>
<li>
<img id="categoryImage" src="img/p/2-54-large.jpg" />
<center>Legende 3</center>
</li>
</ul>
</div>

 

I modified teh code in PHP as the following

 

<?php
$images = array(
	1 => array(
		'product_id' => '12',
		'legend' => 'Petite bague'
		),
	2 => array(
		'product_id' => '6',
		'legend' => 'Petite bague'
		),
	3 => array(
		'product_id' => '3',
		'legend' => 'Petite bague'
		)
	);
?>
<ul id="home_diapo">
<?php
foreach($images as $i => $value){

  echo '<li>';
  echo '<img id="categoryImage" src="img/p/'.$images[$i]['product_id'].'-53-large.jpg" />';
  echo '<p>'.$images[$i]['legend'].'</p>';
  echo '</li>';

}
?>
</ul>

 

 

My problem is the following.

When I replace a prouct image from the admin panel, it does not keep the same name.

 

For exemple

img/p/12-53-large.jpg

 

become (the second number change when we replace the image)

img/p/12-54-large.jpg

 

 

 

I need to know a solution to always "import" the large image of a product, and if I change an image for a product, the PHP script will display the good image name.

 

Now the question is, how can do it with Prestashop "language"?

 

Thank a lot for your help

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