Source Code for /public/appendix-samples/random-image-with-effect.php
<?php
$jpgs = glob('../img/fruit/*.jpg');
$webps = glob('../img/fruit/*.webp');
$files = array_merge( $jpgs, $webps );
$random_file_id = array_rand($files);
$random_file = $files[ $random_file_id ];
$effects = [
'filter: grayscale(100%)',
'filter: blur(2px)',
'filter: brightness(1.5)',
'filter: contrast(1.5)',
'filter: hue-rotate(90deg)',
'filter: invert(1)',
'filter: sepia(1)',
'transform: rotateZ(90deg);',
'transform: skewX(-15deg);',
];
$random_effect_id = array_rand($effects);
$random_effect = $effects[ $random_effect_id ];
?>
<p>
<img src="<?php echo $random_file; ?>"
width="200"
height="200"
style="border: 1px solid black; <?php echo $random_effect; ?>;">
</p>
<ul>
<li>The image that was displayed was: <code><?php echo basename($random_file); ?></code></li>
<li>The effect that was applied was: <code><?php echo $random_effect; ?></code></li>
</ul>
<p>
<a href="/demo-harness.php?file=public/appendix-samples/random-image-with-effect.php">🔄 Get another image/effect</a>
</p>