Created
November 2, 2015 14:54
-
-
Save DrewDouglass/c38ac19bf4cf05464d2e to your computer and use it in GitHub Desktop.
Automate HTML Preview JPGs for Clients
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 | |
//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