Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
no thumbnail
#16
A possible solution here is to use Thumb lib. Just copy "imanager" folder in the plugins directory (an installation is not necessary).

With this function you can loop through all the images in the specified directories and recreate the thumbnails:
PHP Code:
/**
 * Creates thumbnails and cached them
 *
 * @param string $dir - Name for the image folder
 * @param string $target - Name for the thumb folder
 * @param integer/string $width  - Thumb width
 * @param integer $height - Thumb height
 */
function resize($dir$target$width 0$height 0)
{
    include(
GSPLUGINPATH.'imanager/phpthumb/ThumbLib.inc.php');
    if(!
file_exists(GSDATAPATH.'uploads/'.$dir))
    {
        echo 
'Directrory: '.GSDATAPATH.'uploads/'.$dir.' does not exist';
        return 
false;
    }
    if(!
file_exists(GSDATAPATH.'thumbs/'.$target))
    {
        echo 
'Directrory: '.GSDATAPATH.'thumbs/'.$target.' does not exist';
        return 
false;
    }

    
$width = ($width == 0) ? (int) GSIMAGEWIDTH : (int) $width;

    foreach(
glob(GSDATAPATH.'uploads/'.$dir.'/*.{jpg,jpeg,gif,png}'GLOB_BRACE) as $image)
    {
        
$thumb PhpThumbFactory::create($image);
        
$path_parts pathinfo($image);
        
$thumb->resize($width$height);
        
$thumb->save(GSDATAPATH.'thumbs/'.$target.'/thumbnail.'.basename($image), $path_parts['extension']);
    }


Here's an example of this function call, where first parameter is the folder name for images in /data/uploads/ and the second the folder name for thumbnails in /data/thumbs/:

Code:
resize('images', 'images');

You can now delete imanager folder, when no longer required
Reply


Messages In This Thread
no thumbnail - by Oleg06 - 2016-10-08, 05:08:08
RE: no thumbnail - by shawn_a - 2016-10-08, 08:11:51
RE: no thumbnail - by Oleg06 - 2016-10-08, 18:18:35
RE: no thumbnail - by shawn_a - 2016-10-08, 23:26:05
RE: no thumbnail - by Oleg06 - 2016-10-09, 01:10:30
RE: no thumbnail - by shawn_a - 2016-10-09, 01:24:01
RE: no thumbnail - by Oleg06 - 2016-10-09, 02:06:12
RE: no thumbnail - by shawn_a - 2016-10-09, 08:09:51
RE: no thumbnail - by shawn_a - 2016-10-10, 01:17:13
RE: no thumbnail - by shawn_a - 2016-10-10, 02:01:29
RE: no thumbnail - by Oleg06 - 2016-10-10, 05:57:44
RE: no thumbnail - by shawn_a - 2016-10-10, 06:32:06
RE: no thumbnail - by shawn_a - 2016-10-12, 01:44:09
RE: no thumbnail - by Oleg06 - 2016-10-12, 04:32:10
RE: no thumbnail - by morvy - 2017-03-09, 18:49:32
RE: no thumbnail - by Bigin - 2017-03-09, 22:55:07
RE: no thumbnail - by morvy - 2017-03-10, 01:51:47



Users browsing this thread: 1 Guest(s)