public static function get_image_by_height($path, $height = "original") { if ($path instanceof File) { $image_file = $path; } else { $image_file = new File($path); } $image_dir = $image_file->getDirectory(); $full_cache_dir = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath()); $full_cache_dir->touch(); $data = ImageUtils::get_image_data($image_file); if ($height == "original") { $thumb_folder = "original"; } else { if ($data["height"] > $height) { $thumb_folder = "__x" . $height; } else { $thumb_folder = "original"; } } if ($thumb_folder == "original") { return $image_file->getPath(); } $final_image_folder = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath() . $thumb_folder); //copio l'immagine nella cache $final_image_folder->touch(); $thumbnail_image_file = $final_image_folder->newFile($image_file->getFilename()); if (!$thumbnail_image_file->exists()) { ImageUtils::resize_by_height($image_file, $thumbnail_image_file, $height); } return $thumbnail_image_file->getPath(); }
<?php $prodotto_servizio = call("prodotto_servizio", "get", array("id_prodotto_servizio" => Params::get("id_prodotto_servizio"))); $immagini_prodotto_servizio = call("prodotto_servizio", "index_immagini", array("__filter_id_prodotto_servizio__EQUAL" => Params::get("id_prodotto_servizio"))); $total_width = 0; foreach ($immagini_prodotto_servizio as $img) { $image_data = ImageUtils::get_image_data(image_h(ProdottoServizioController::PRODUCT_IMAGE_DIR . "/" . $prodotto_servizio["id_prodotto_servizio"] . "/" . $img["nome_immagine"], 200)); $total_width += $image_data["width"] + 10; } ?> <div> <div align="center"> <h2 style="font-size:20px;font-family:fantasy;"><?php echo $prodotto_servizio["nome"]; ?> </h2> <br /> <?php foreach ($immagini_prodotto_servizio as $img) { ?> <div style="padding:5px;display:inline-block;"> <img src="<?php echo image_h(ProdottoServizioController::PRODUCT_IMAGE_DIR . "/" . $prodotto_servizio["id_prodotto_servizio"] . "/" . $img["nome_immagine"], 200); ?> " alt="" /> </div> <?php } ?>