In dem folgenden Modul wird die maximale Breite von 342 überprüft. Diese Zahl ist natürlich veränderbar. So soll also eine maximale Breite von 342 pixel eines Bildes gewährleistet werden. Und damit dann auch noch die Höhe in der Relation verändert wird, folgt dann also noch eine kleine Rechnung.
Hier nun das MODUL (MAXIMAL BILD):
Code: Alles auswählen
<?php
if ("CMS_IMG[8]" != "") {
$size = getimagesize("CMS_IMG[8]");
$width = $size[0];
$height = $size[1];
if ($width > 342)
{
$width = 342;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
$img = '<img src="CMS_IMG[8]" width="'.$width.'" height="'.$height.'" >';
echo $img;
}
echo "CMS_IMGDESCR[8]";
?>
Hier nun der Code mit Hyperlink-Funktion:
Code: Alles auswählen
<?php
if ("CMS_IMG[1]" != "") {
$size = getimagesize("CMS_IMG[1]");
$width = $size[0];
$height = $size[1];
if ($width > 342)
{
$width = 342;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
$img = '<img src="CMS_IMG[1]" width="'.$width.'" height="'.$height.'" border="0">';
if ("CMS_LINK[1]" != "http://") {
$img = sprintf('<a href="%s" target="%s">%s</a>',"CMS_LINK[1]", "CMS_LINKTARGET[1]", $img);
}
echo $img;
}
echo "CMS_IMGDESCR[1] CMS_LINKDESCR[1]";
?>