Quote:
Originally Posted by Dmitriy
By the way, I just added an auto-resize for attached images to keep images under the max size. Basically the same think, edit the functions.php in the same manner (almost):
if ($extension=="gif" or $extension=="jpg" or $extension=="jpeg" or $extension=="jpe" or $extension=="png" or $extension=="swf") { // Picture file
if ($imginfo=@getimagesize($attachment)) {
if (($maxattachwidth>0 and $imginfo[0]>$maxattachwidth) or ($maxattachheight>0 and $imginfo[1]>$maxattachheight)) {
$image_width = $imginfo[0];
$image_height= $imginfo[1];
if ($image_width > $maxattachwidth)
{
$sizefactor = (double) ($maxattachwidth / $image_width);
}
elseif ($image_height > $maxattachheight)
{
$sizefactor = (double) ($maxattachheight / $image_height) ;
}
$newwidth = (int) ($image_width * $sizefactor);
$newheight = (int) ($image_height * $sizefactor);
$newsize = $newwidth . "x" . $newheight;
$cmd = "/usr/local/bin/mogrify -resize $newsize "."$attachment 2>&1";
exec($cmd, $exec_output, $exec_retval);
if($exec_retval > 0)
{
print "ERROR: exec() error: $exec_output[0]";
}
else
{
print "<P align=\"center\"><b>Image was resized from " . $image_width . "x" .
$image_height . " to $newsize</p>";
}
}
|
what code in my current functions.php do I replace your code with???