Jump to content

Images are not regenerating properly


Recommended Posts

Hi,

 

I have upgraded the prestashop from 1.4.X to 1.6.X(latest and stable ver), everything went in flow but I am not able to get the images nor I am able to regenerate them again. I am getting the following warning which show Images are missing and its really difficult to sort out 500 images and put them manually in different folders.

 

522 errors 

  1. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/1.jpg) for product ID 1
  2. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/2/2.jpg) for product ID 2
  3. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/4/4.jpg) for product ID 4
  4. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/5/5.jpg) for product ID 4
  5. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/6/6.jpg) for product ID 4
  6. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/1/11.jpg) for product ID 7
  7. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/3/13.jpg) for product ID 7
  8. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/4/14.jpg) for product ID 8
  9. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/5/15.jpg) for product ID 8
  10. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/6/16.jpg) for product ID 8
  11. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/7/17.jpg) for product ID 8
  12. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/1/9/19.jpg) for product ID 8
  13. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/2/0/20.jpg) for product ID 8
  14. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/2/1/21.jpg) for product ID 9
  15. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/2/2/22.jpg) for product ID 10
  16. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/2/3/23.jpg) for product ID 11
  17. Original image is missing or empty (/home/livecode/public_html/canfora/img/p/2/4/24.jpg) for product ID 11..................................................

I am looking for a way out or some extra addon or module or any thing which can help in putting my images back. I have the backup of images folder which can help me out in regenerating if someone guide me. Thank you!

 

Regards

Andy

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

Hi,

 

I think this might be the issue with other people also, so I build a small script which will manually convert the presta 1.4.X images to presta 1.6.X standards with sub-directories. please find the code below and it will run like a dragon. To use the following code you have to follow the steps below in your WAMP:-

 

1. Create a directory or a project folder in your WAMP say "convertImages1.4To1.6".

2. Copy the given below code and save it in the file naming "index.php" in the above folder.

3. Create a folder "img" in the directory "convertImages1.4To1.6" right next to "index.php" file and the path will look like "convertImages1.4To1.6/img/".

4. This is the step you have to follow with care, please copy the image files from the folder "/img/p/" of presta 1.4 to "convertImages1.4To1.6/img/". Please copy the original files only which says the name like "1-1.jpg,1-2.jpg,................,7-742.jpg,8-1.jpg" and neglect the files which generated after thumbnail regeneration from the back-office.

5. Now open your browser and run the URL - "http://localhost/convertImages1.4To1.6/". By running this script a new folder naming "p" will be created and all the images will be copied from "convertImages1.4To1.6/img/" to "convertImages1.4To1.6/p/" with accurate sub directories.

6. Now merge your "convertImages1.4To1.6/p/" folder with your shop image folder "presta1.6(your-website)/p/" and rerun the thumbnail regeneration from the back-office. All the other images will be regenerated and you are good to go.

 

Please comment if this thing solved your issue. Thanks a lot and Happy coding!

 

<?php

 

define('_BASE_PATH_',dirname(__FILE__)); //The base path of the directory

$imgDir = _BASE_PATH_.'/img/'; //Directory in which images are present
$outputDir = _BASE_PATH_.'/p/'; //Directory in which you want to keep the files after processing
$imageArray = scandir($imgDir,0); //Scan all the files in the directory
 
if(!file_exists($outputDir)):
 
mkdir($outputDir);//It will make the output directory
 
endif;
 
$cnt='0';
$filesCreated = array();
foreach($imageArray as $key=>$val):
 
 
 
$oldFile = $imgDir.$val;
 
$tmpFileArray = (explode('-',$val));
$fileName = $tmpFileArray['1'];// The final file name which has to be saved in output directory
 
$tmp = (explode('.',$fileName));
$tmpDirArray = str_split($tmp['0'],1);//Remove the extension from the file
 
$finalDir = $outputDir;
 
foreach($tmpDirArray as $subDir):
 
$finalDir .= $subDir.'/';
 
if(!file_exists($finalDir)):
 
mkdir($finalDir);//It will make directories and internal directories
 
endif;
 
endforeach;
 
if(!copy($oldFile,$finalDir.$fileName)):
 
echo 'Error copying file : '.$finalDir.$fileName;//If any issue occur while copying, it will display the error
 
endif;
 
endif;
 
$filesCreated[] = $finalDir.$fileName;//List of files copied
 
unset($fileName,$finalDir,$oldFile,$newFile,$tmpFileArray,$tmp,$tmpDirArray);//Unset all variables of foreach loop to use them again
 
$cnt++;
 
endforeach;
echo $fileName;
echo '<pre>Total number of files copied : '.$cnt.'<br>';
print_r($filesCreated);
echo '</pre>';
 
?>
Edited by jsmwebsolutions (see edit history)
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...