PHPFusion\Forums\Functions::display_image_attach PHP Метод

display_image_attach() публичный статический Метод

Display attached image with a certain given width and height.
public static display_image_attach ( $file, integer $width = 50, integer $height = 50, string $rel = "" ) : string
$file
$width integer
$height integer
$rel string
Результат string
    public static function display_image_attach($file, $width = 50, $height = 50, $rel = "")
    {
        $size = @getimagesize(INFUSIONS . "forum/attachments/" . $file);
        if ($size[0] > $height || $size[1] > $width) {
            if ($size[0] < $size[1]) {
                $img_w = round($size[0] * $width / $size[1]);
                $img_h = $width;
            } elseif ($size[0] > $size[1]) {
                $img_w = $height;
                $img_h = round($size[1] * $height / $size[0]);
            } else {
                $img_w = $height;
                $img_h = $width;
            }
        } else {
            $img_w = $size[0];
            $img_h = $size[1];
        }
        $res = "<a target='_blank' href='" . INFUSIONS . "forum/attachments/" . $file . "' rel='attach_" . $rel . "' title='" . $file . "'><img class='img-thumbnail' src='" . INFUSIONS . "forum/attachments/" . $file . "' alt='" . $file . "' style='border:0px; width:" . $img_w . "px; height:" . $img_h . "px;' /></a>\n";
        return $res;
    }