Created
February 16, 2018 17:41
-
-
Save luancmaia/1edaa700d675f3520632fc0a3be4deba to your computer and use it in GitHub Desktop.
tinify cron job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//pattern examples: '*.jpg', '*_GREEN.png', 'file.jpg' | |
$rq = exec("find . -name 'YOUR_PATTERN_HERE'", $out, $err); | |
require_once("vendor/autoload.php"); | |
$tinify_key = ''; | |
if ( !empty($out) ){ | |
$images = $out; | |
foreach($images as $image) { | |
Tinify\setKey($tinify_key); | |
Tinify\fromFile($image)->toFile($image); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment