Bild verreisst die Tabelle!!!
Verfasst: Mo 3. Apr 2006, 12:09
Hallo habe vor kurzem dieses Modul gefunden, bin eigentlich sehr zufrieden nur eins macht mir Kummer es verwirft mir die ganze Tabelle wenn ich ein Bild mit dem Modul lade... Wenn ich es einfach einfüge geht es also muss es am Modul liegen... Hier noch ein Printscreen:
Input:
output:

Input:
Code: Alles auswählen
if ( "CMS_VALUE[5]" )
{
$thm_dir="CMS_VALUE[5]";
}
else
{
$thm_dir = defined(THUMB_DIR)? THUMB_DIR: "thm"; // thumb dir - default "thm"
}
echo '<table cellspacing="0" cellpadding="10" border="0">';
echo '<tr><td>Thumb Verzeichnis (optional):</td>';
echo '<td><input type="text" name="CMS_VAR[5]" value="CMS_VALUE[5]" size="30" /></td></tr>';
echo '<tr><td>Maximale Breite Thumbs:</td>';
echo '<td><input type="text" name="CMS_VAR[6]" value="CMS_VALUE[6]" size="4" />px</td></tr>';
echo '<tr><td>Maximale Höhe Thumbs:</td>';
echo '<td><input type="text" name="CMS_VAR[7]" value="CMS_VALUE[7]" size="4" />px</td></tr>';
echo '<tr><td>Qualität Thumbs (optional):</td>';
echo '<td><input type="text" name="CMS_VAR[9]" value="CMS_VALUE[9]" size="3" />%</td></tr>';
$align = "CMS_VALUE[10]";
$opts = array ( "","absbottom","absmiddle","baseline","bottom","left","middle","right","texttop","top" );
echo '<tr><td>Ausrichtung Thumb (optional):</td>';
echo '<td><select name="CMS_VAR[10]">';
foreach ( $opts as $v )
{
$sel = ( $align==$v? "selected": "" );
echo "<option value=\"$v\" $sel>$v</option>";
}
echo '</select></td></tr>';
echo "<tr><td>Popup aktivieren:</td>";
$pop = "CMS_VALUE[8]";
$chk = ( $pop>""? "checked": "" );
echo '<td><input type="checkbox" name="CMS_VAR[8]" value="true" size="3" '.$chk.' /></td></tr>';
echo "</table>";
Code: Alles auswählen
<?php
$viewer = "/src/viewer.php"; // image viewer for popups
$thm_dir = "CMS_VALUE[5]"? "CMS_VALUE[5]": "thm"; // thumb dir - default "thm"
$thm_maxw = intval("CMS_VALUE[6]"); // max width thumb
$thm_maxh = intval("CMS_VALUE[7]"); // max height thumb
$thm_qual = "CMS_VALUE[9]"? intval("CMS_VALUE[9]"): 80; //quality jpeg
$show_popup = "CMS_VALUE[8]"? true: false; // show popup yes/no
$align = "CMS_VALUE[10]"? 'align="CMS_VALUE[10]"': ""; // align thumb
$img_dir = $cfg['path']['frontend']; // base dir frontend
$img_src = "CMS_IMG[10]"; // src of image
$img_lnk = "CMS_LINK[10]"; // image link
$img_tgt = "CMS_LINKTARGET[10]"; // target of imagelink
$img_url = parse_url($img_src);
$img_path = "$img_dir".$img_url['path'];
if ( $img_src && file_exists($img_path) )
{
unset ($ratio);
$img_size = getimagesize ($img_path);
if ( $thm_maxw>0 )
{
$ratio = $thm_maxw/$img_size[0];
$thm_w = $thm_maxw;
$thm_h = round($ratio*$img_size[1]);
}
if ( $thm_maxh>0 )
{
$rh = $thm_maxh/$img_size[1];
$ratio = ( $ratio>$rh? $rh: $ratio );
$thm_w = round($ratio*$img_size[0]);
$thm_h = $thm_maxh;
}
$thm_src = $img_src;
if ( is_numeric($ratio) && $ratio<1 )
{
// use thumb, resize image
$thm_src = dirname($img_src)."/$thm_dir/".basename($img_src);
$thm_path = dirname($img_path)."/$thm_dir/".basename($img_path);
$flag_create = !file_exists($thm_path);
if ( !$flag_create )
{
$thm_size = getimagesize ( $thm_path );
if ( !$thm_size || $thm_size[0]!=$thm_w )
{
$flag_create = true;
}
}
if ( $flag_create )
{ // make thumb
if ( !file_exists(dirname($thm_path)) ) mkdir(dirname($thm_path),0777);
unset($i);
switch ( exif_imagetype($img_path) )
{
case IMAGETYPE_GIF:
$i = imagecreatefromgif($img_path);
break;
case IMAGETYPE_JPEG:
$i = imagecreatefromjpeg($img_path);
break;
case IMAGETYPE_PNG:
$i = imagecreatefrompng($img_path);
break;
case IMAGETYPE_BMP:
$i = imagecreatefromwbmp($img_path);
break;
case IMAGETYPE_SWF:
case IMAGETYPE_PSD:
case IMAGETYPE_TIFF_II:
case IMAGETYPE_TIFF_MM:
case IMAGETYPE_JPC:
case IMAGETYPE_JP2:
case IMAGETYPE_JPX:
case IMAGETYPE_SWC:
default:
$i = imagecreatefromxbm($fsrc);
} //detect image type
if ( $i )
{
$thm = imagecreatetruecolor($thm_w,$thm_h);
imagecolortransparent($thm,imagecolorat($i,0,0));
imagecopyresampled($thm,$i,0,0,0,0,$thm_w,$thm_h,$img_size[0],$img_size[1]) &&
imagejpeg($thm,$thm_path,$thm_qual);
imagedestroy($thm);
imagedestroy($i);
}
} // create thumb
} // $ratio<1
$img = sprintf('<img src="%s" border="0" %s>',$thm_src,$align);
$slf = "http://" . $_SERVER['HTTP_HOST'] . dirname($PHP_SELF) . "/";
if ( $img_lnk != "http://" && $img_lnk != $slf )
{
$img = sprintf('<a href="%s" target="%s">%s</a>',$img_lnk,$img_tgt,$img);
}
elseif ( $show_popup )
{
$img = sprintf('<a href="%s?img=%s" target="_blank">%s</a>',$viewer,urlencode($img_src),$img );
}
echo $img;
} // $img_src!=""
if ( $contenido || "CMS_IMGDESCR[10]" )
{
echo "<br>";
echo "CMS_IMGDESCR[10]";
}
if ( $contenido || "CMS_LINKDESCR[10]" )
{
echo "<br>";
echo "CMS_LINKDESCR[10]";
}
echo "<br>";
?>