<?php require_once 'Image.php'; define('IMAGEPATH', 'images/'); $sizes = getSizes(); $image = resize(getRandomImage(), $sizes['width'], $sizes['height']); header('Content-Type: image/jpeg'); header("HTTP/1.1 200 OK"); imagejpeg(readfile($image, 'r')); function getRandomImage() { $images = []; foreach (glob(IMAGEPATH . '*') as $filename) { $images[] = '/' . basename($filename); } return $images[rand(0, count($images) - 1)]; } function getSizes() { preg_match("/([0-9]+)x([0-9]+)/", $_SERVER['REQUEST_URI'], $arr); return ['width' => isset($arr[1]) ? $arr[1] : 200, 'height' => isset($arr[2]) ? $arr[2] : 200]; } function resize($filename, $width, $height) { $filename = trim($filename, '/'); if (!is_file(IMAGEPATH . $filename)) { return; } $extension = pathinfo($filename, PATHINFO_EXTENSION); $old_image = $filename; $new_image = 'cache/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
<div class="container-fluid"> <div class="row"> <div class="col-xs-4"> <div class="panel panel-warning"> <div class="panel-body"> <form> <div class="form-group"> <label for="color_label">Color: </label> <?php getColors(); ?> </div> <div class="form-group"> <label for="talla_label">Talla: </label> <?php getSizes(); ?> </div> <div class="form-group"> <label for="model_label">Modelo: </label> <?php getModels(); ?> </div> <button type="button" class="btn btn-primary" id="search_shoe"><i class="icon-search icon-small"></i> Buscar</button> <a target="_self" href="#" class="btn btn-success pull-right play-qr" id="search-shoe-qr"><i class="icon-qrcode icon-small"></i> Buscar con QR</a> </form> </div> </div> </div> <div class="col-xs-4">