[eluser]NetStranger[/eluser]
i need to make thumbs for lots of images in the folder once... and i right this code :
Code:
$data = directory_map('./img/photo/'.$page);
foreach ($data as $val => $img) // images in photo
{
if (!is_array($img)) // if it is not array
{
$must_thumb = '';
foreach ($data['thumbs'] as $val2 => $img2) // path to thumb
{
if (substr($img2, 0, -10) == substr($img, 0, -4))
{
$must_thumb = '/img/photo/'.$page.'/thumbs/'.$img2;
}
}
$thumb = '/img/photo/'.$page.'/thumbs/'.substr($img, 0, -4)."-thumb".substr($img, -4); // thumb
echo '<h1>'.$must_thumb.'='.$thumb.'</h1>';
if ($must_thumb != $thumb) // if there is no thumb realy
{ // make thumb
echo "<h2>".$check."</h2>";
$check = ++$check;
$config['image_library'] = 'gd2';
$config['source_image'] = './img/photo/'.$page.'/'.$img;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 150;
$config['height'] = 100;
$config['thumb_marker'] = "-thumb";
$config['new_image'] = './img/photo/'.$page.'/thumbs/'.$img;
$this->load->library('image_lib', $config);
if ( ! $this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
echo "<img src='".$thumb."' />";
echo '<br />';
}
else
{
echo "<img src='".$thumb."' />";
echo '<br />';
}
}
}
but it's not work correctly. when i load page, thumb makes for first picture ONLY! other pictures dont create thumb . Then i do refresh of the page and NEXT picture get its thumb BUT third - not... etc .Why ? where my mistake?? thanks