Welcome Guest, Not a member yet? Register   Sign In
Vairable Question
#3

(04-15-2015, 07:53 AM)CroNiX Wrote: I don't understand why you're doing it this way if they are copies of the same image in different directories. Since they're DIFFERENT, the filename can be the same in both and you don't need to mess with that.

$image = 'some-image.png';

unlink('/path/to/regular/images/' . $image);
unlink('/path/to/cached/images/' . $image);

But to answer your question, can't you just use image functions to get the width/height of the image before you delete it?


PHP Code:
foreach ($path_post as $path) {
 
 $file_name FCPATH '/image/' $path;

 
 //check to make sure image exists
 
 if (file_exists($file_name))
 
 {
 
   //get height/width of image
 
   list($height$width) = getimagesize($file_name);

 
   //build the cached image file name
 
   $extension pathinfo($pathPATHINFO_EXTENSION);
 
   $cached_image FCPATH 'image/cache/' utf8_substr($path0utf8_strrpos($path'.')) . '-' $width 'x' $height '.' $extension;

 
   //delete cached image
 
   unlink($cached_image);

 
   //delete regular image
 
   unlink($file_name);
 
    


I will look more into it. Thanks for pointing it out. All ways happy to learn.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
Vairable Question - by wolfgang1983 - 04-15-2015, 03:59 AM
RE: Vairable Question - by CroNiX - 04-15-2015, 07:53 AM
RE: Vairable Question - by wolfgang1983 - 04-15-2015, 09:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB