Skip to content

Instantly share code, notes, and snippets.

@DrewDouglass
Created November 2, 2015 14:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrewDouglass/c38ac19bf4cf05464d2e to your computer and use it in GitHub Desktop.
Save DrewDouglass/c38ac19bf4cf05464d2e to your computer and use it in GitHub Desktop.
Automate HTML Preview JPGs for Clients
<?php
//While <= number of files to create
$count = 1;
while($count <= 18) {
if($count === 1) {
$filename = 'index.html';
}
else {
$filename = $count.'.html';
}
if($count === 18){
$linkto = 'index.html';
}
else {
$linkto = $count+1 . '.html';
}
$img = 'img/'.$count.'.jpg';
$html = <<<EOD
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Paulo</title>
<style type="text/css">
img {
margin:0 auto;
max-width:100%;
height:auto;
display:block
}
</style>
</head>
<body>
<a href="$linkto"><img src="$img" alt=""></a>
</body>
</html>
EOD;
$fh = fopen($filename, 'w');
fwrite($fh, $html);
fclose($fh);
echo "File ".$count.".html created.";
echo "<br><br>";
$count++;
}
echo "Robot done, unplug me.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment