| Server IP : 172.67.178.83 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/findnextproperty.com/frontend/components/ |
Upload File : |
<?php
namespace frontend\components;
use common\models\Image;
use yii\helpers\BaseArrayHelper;
use yii\helpers\Html;
use Yii;
class ImageHelper extends BaseArrayHelper
{
public static function show($url = null, $alt = null, $width = null, $height = null)
{
//vd($url);
// если нет картинки
if ($url == null) {
echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:200px;width:100%']);
return false;
}
if (isset($url) && $url != '/images/bed.gif' && $url != '/images/bath.gif') {
// echo $url;
echo Html::img($url, ['alt' => $alt, 'height' => $height, 'style' => 'height:200px;width:100%']);
} else {
//echo $url;
echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:300px;width:100%']);
}
}
public static function showBig($url = null, $alt = null, $width = null, $height = null)
{
//vd($url);
// если нет картинки
if ($url == null) {
echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:300px;width:100%']);
return false;
}
if (isset($url[0]) && $url[0] != '/images/bed.gif' && $url[0] != '/images/bath.gif') {
// echo $url;
echo Html::img($url[0], ['alt' => $alt, 'height' => $height, 'style' => 'height:600px;width:100%']);
} elseif (isset($url[1]) && $url[1] != '/images/bed.gif' && $url[1] != '/images/bath.gif') {
// echo $url;
echo Html::img($url[1], ['alt' => $alt, 'height' => $height, 'style' => 'height:600px;width:100%']);
} elseif (isset($url[2]) && $url[2] != '/images/bed.gif' && $url[2] != '/images/bath.gif') {
// echo $url;
echo Html::img($url[2], ['alt' => $alt, 'height' => $height, 'style' => 'height:600px;width:100%']);
} else {
//echo $url;
echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:300px;width:100%']);
}
}
// выведет первую картинку bp vfccbdf
public static function showFirst($url = null, $alt = null, $width = null, $height = null)
{
//vd($url);
if (empty($url)) {
echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:200px;width:100%']);
return false;
}
if (isset($url[0]) && $url[0] != '/images/bed.gif' && $url[0] != '/images/bath.gif') {
// echo $url;
echo Html::img($url[0], ['alt' => $alt, 'height' => $height, 'style' => 'height:200px;width:100%']);
} elseif (isset($url[1]) && $url[1] != '/images/bed.gif' && $url[1] != '/images/bath.gif') {
// echo $url;
echo Html::img($url[1], ['alt' => $alt, 'height' => $height, 'style' => 'height:200px;width:100%']);
} elseif (isset($url[2]) && $url[2] != '/images/bed.gif' && $url[2] != '/images/bath.gif') {
// echo $url;
echo Html::img($url[2], ['alt' => $alt, 'height' => $height, 'style' => 'height:200px;width:100%']);
} else {
//echo $url;
echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:300px;width:100%']);
}
}
// вывод первой нормальной картинки
public static function FirstBig($arr = null, $alt = null, $width = null, $height = null)
{
//vd($arr);
foreach ($arr as $key => $image) {
if (strlen($image) > 20) {
if (isset($active) && $active == true) {
echo '<div class="item">' . Html::img($image, ['alt' => $alt, $height, 'style' => 'max-height:870px;width:100%']) . '</div>';
} else {
echo '<div class="item active">' . Html::img($image, ['alt' => $alt, $height, 'style' => 'max-height:870px;width:100%']) . '</div>';
$active = true;
}
//break;
} else {
// default;
//echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:870px;width:100%']);
break;
}
}
}
// коректный вывод тумбочек
public static function Thumb($url = null, $alt = null, $width = null, $height = null, $i = null)
{
if (strlen($url) > 20) {
echo '<li data-target="#myCarousel" data-slide-to="' . $i . '" class="">' . Html::img($url, ['alt' => $alt, $height, 'style' => 'max-height:870px;width:100%']) . '</li>';
} else {
// default;
//echo Html::img('/images/default.jpg', ['alt' => $alt, $height, 'style' => 'max-height:870px;width:100%']);
}
}
public static function chekUrl($url)
{
$Headers = @get_headers($url);
if (strpos('200', $Headers[0])) {
return true;
} else {
return false;
//echo "Файл не найден";
}
}
public static function showDefault($house_id, $template = null)
{
$class = isset($template) && $template == 'realtor' ? 'img-responsive' : 'item';
$div_class = isset($template) && $template == 'realtor' ? 'img' : 'item';
//vd($class);
$model = Image::find()->where(['house_id' => $house_id, 'default' => 1, 'status' => 1])->one();
if (!$model) {
$model = Image::find()->where(['house_id' => $house_id, 'default' => 0, 'status' => 1])->one();
}
if ($model && file_exists(Yii::getAlias('@images') . '/' . $model->localpath)) {
$path = '/static/images/' . $model->localpath;
echo '<div class="'. $div_class .'">' . Html::img($path, ['height' => '200','style' => 'max-height:270px;width:100%', 'alt' => 'image','class'=> $class]) . '</div>';
} else {
echo '<div class="'. $div_class .'">' . Html::img('/images/default.jpg', ['height' => '200','style' => 'max-height:270px;width:100%', 'alt' => 'image','class'=>$class]) . '</div>';
}
}
public static function CorrectSrc($path = null)
{
// echo Yii::getAlias('@images').'/'.$model->localpath;die;
if (!$path || !file_exists(Yii::getAlias('@images') . '/' . $path)) {
return '/images/default.jpg';
} else {
return '/static/images/' . $path;
}
// vd(Yii::getAlias('@images').'/'.$path);
if (file_exists(Yii::getAlias('@images') . '/' . $path)) {
return '/static/images/' . $path;
} else {
return '/images/default.jpg';
}
}
public static function IsExist($imageObject)
{
$url = $imageObject->localpath;
if ($url == null) {
return false;
}
if (!file_exists(Yii::getAlias('@images') . '/' . $url)) {
return false;
} else {
return true;
}
}
}