Adapter le 2 scripts php ,pour un redimensionnement d'image
Bonjour,
Je souhaiterai avoir un redimensionnement de mes images à la volée mais je ne sais pas adapter le script au code que j'ai deja :
Code de mon site :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => BOX_HEADING_SPECIALS);
new infoBoxHeading($info_box_contents, false, false, tep_href_link(FILENAME_SPECIALS));
$info_box_contents = array();
$info_box_contents[] = array('align' => 'center',
'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . $random_product['products_name'] . '</a><br><s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>');
new infoBox($info_box_contents);
?> |
et voici le code que j'ai trouvé , que j'aimerai adapter a celui de dessus :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
<?
function redimage($img_src,$dst_w,$dst_h) {
// Lit les dimensions de l'image
$size = GetImageSize($img_src);
$src_w = $size[0]; $src_h = $size[1];
// Teste les dimensions tenant dans la zone
$test_h = round(($dst_w / $src_w) * $src_h);
$test_w = round(($dst_h / $src_h) * $src_w);
// Si Height final non précisé (0)
if(!$dst_h) $dst_h = $test_h;
// Sinon si Width final non précisé (0)
elseif(!$dst_w) $dst_w = $test_w;
// Sinon teste quel redimensionnement tient dans la zone
elseif($test_h>$dst_h) $dst_w = $test_w;
else $dst_h = $test_h;
// Affiche les dimensions optimales
echo "WIDTH=".$dst_w." HEIGHT=".$dst_h;
}
?>
<IMG SRC="monimage.jpg" <?redimage("monimage.jpg",XX,YY)?>> |
Code:
SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT
etant mes images via la base de donnee.
Est ce possible ?
Merci de votre aide