Пример #1
0
 public function testCleanThumbnails()
 {
     $thumbnailPath = $this->autoThumb->getDocumentRoot() . DIRECTORY_SEPARATOR . $this->autoThumb->getThumbnail($this->variables['image'], $this->variables['type']);
     if (file_exists($thumbnailPath)) {
         unlink($thumbnailPath);
     }
     $this->autoThumb->process($this->variables, false);
     $this->autoThumb->cleanThumbnails('images/');
     $this->assertFalse(file_exists($thumbnailPath), 'Clean thumbnails in specified directory does not work.');
     $this->autoThumb->process($this->variables, false);
     $this->autoThumb->cleanThumbnails($this->variables['image']);
     $this->assertFalse(file_exists($thumbnailPath), 'Clean thumbnails for one image does not work.');
 }
Пример #2
0
<?php

/**
 * Created: 2016-05-17
 * @author Yauhen Saroka <*****@*****.**>
 */
require_once dirname(__FILE__) . '/vendor/autoload.php';
use ysaroka\autothumb\AutoThumb;
$autothumb = new AutoThumb(require_once dirname(__FILE__) . '/autothumb.config.php');
if (isset($_GET['regenerate'])) {
    $autothumb->cleanThumbnails('images');
    header('Location: /index.php');
    exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Autohumb demo project</title>
</head>
<body>
<a href="index.php?regenerate=1">Regenerate all thumbnails</a>

<div style="text-align: center">
    <div><img src="<?php 
echo $autothumb->getThumbnail('images/original-image-1024x768.jpg', 'small');
?>
" />
    </div>
    <div>Thumbnail type "small".</div>