当前位置: 首页>>代码示例>>PHP>>正文


PHP Html::img方法代码示例

本文整理汇总了PHP中yii\helpers\Html::img方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::img方法的具体用法?PHP Html::img怎么用?PHP Html::img使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Html的用法示例。


在下文中一共展示了Html::img方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $view = $this->getView();
     $kcfinder = KCFinderAsset::register($view);
     if ($this->hasModel()) {
         if (!empty($this->model->icon)) {
             $this->src = $this->model->icon;
         }
     }
     //$this->options = array_merge($this->options, ['onclick'=>'openKCFinder(this);']);
     echo Html::tag('div', Html::img($this->src, ['id' => $this->widget['id'] . '-preview', 'class' => 'img-responsive']), ['class' => 'well well-sm text-center', 'style' => 'margin:5px;']);
     echo '<div class="input-group">';
     if ($this->hasModel()) {
         echo Html::activeTextInput($this->model, $this->attribute, $this->options);
     } else {
         echo Html::textInput($this->name, $this->value, $this->options);
     }
     echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-clear"><i class="glyphicon glyphicon-remove"></i></button></span>';
     echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-browse"><i class="glyphicon glyphicon-folder-open"></i></button></span>';
     echo '</div>';
     $session = Yii::$app->session;
     if (!$session->has('KCFINDER')) {
         $session->set('KCFINDER', ['disabled' => false, 'uploadDir' => $this->uploadDir, 'uploadURL' => $this->uploadURL]);
         $htSource = __DIR__ . '/upload.htaccess';
         $htDest = $kcfinder->basePath . '/conf/upload.htaccess';
         copy($htSource, $htDest);
     }
     $this->registerJs();
 }
开发者ID:kuakling,项目名称:yii2-keditor,代码行数:32,代码来源:KCFinderTextInput.php

示例2: render

 public function render($type)
 {
     $image = $this->image;
     if (!$image) {
         $image = $this->desktop->assetsUrl . '/images/icon_application.png';
     } else {
         if (\yii\helpers\Url::isRelative($image) && $this->desktop->iconPath) {
             $image = rtrim($this->desktop->iconPath, '/') . '/' . $image;
         }
     }
     $attributes = ['src' => $image];
     $styles = [];
     switch ($type) {
         case self::DISPLAY_MENU:
             $styles = ['height' => '16px', 'position' => 'relative', 'top' => '-2px'];
             break;
         case self::DISPLAY_DOCK:
             $styles = ['height' => '16px'];
             break;
         case self::DISPLAY_TITLEBAR:
             $styles = ['float' => 'left', 'margin' => '4px 5px 0 0', 'height' => '20px'];
             break;
         case self::DISPLAY_DESKTOP:
             $styles = ['height' => '32px'];
             break;
     }
     Html::addCssStyle($attributes, $styles);
     return Html::img($attributes['src'], $attributes);
 }
开发者ID:bedezign,项目名称:yii2-desktop,代码行数:29,代码来源:Icon.php

示例3: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $jsOptions = ['clientOptions' => $this->clientOptions];
     $this->options['id'] = 'input-id';
     if ($this->hasModel()) {
         echo Html::activeInput('file', $this->model, $this->attribute, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
         $input_name = Html::getInputName($this->model, $this->attribute);
         $input_id = Html::getInputId($this->model, $this->attribute);
         echo Html::hiddenInput($input_name . '[file]', '', ['id' => $input_id . '_image']);
         $jsOptions['model'] = $this->model;
         $jsOptions['attribute'] = $this->attribute;
     } else {
         echo Html::fileInput($this->name, $this->value, $this->options);
         echo Html::img('#', ['id' => 'cropper-box']);
         echo Html::button('Crop', ['id' => 'cropImage']);
     }
     if ($this->uploadUrl) {
         $this->uploadUrl = \Yii::getAlias($this->uploadUrl);
     }
     $jsOptions['uploadUrl'] = $this->uploadUrl;
     $jsOptions['uploadCroppedUrl'] = $this->uploadCroppedUrl;
     $jsOptions['changeUrl'] = $this->changeUrl;
     $jsOptions['name'] = $this->name;
     $jsOptions['aspectRatio'] = $this->aspectRatio;
     $this->registerPlugin($jsOptions);
 }
开发者ID:servsol,项目名称:yii2-cropper,代码行数:31,代码来源:Cropper.php

示例4: getHtml

 /**
  * @inheritdoc
  */
 public function getHtml()
 {
     $content = Html::img($this->img, ['alt' => $this->title, 'title' => $this->title]);
     $content .= Html::tag('span', '', ['class' => 'hp', 'data-type' => 'hp']);
     $content .= Html::tag('span', '', ['class' => 'mp', 'data-type' => 'mp']);
     return Html::tag('div', $content, ['data-type' => $this->type]);
 }
开发者ID:h11Nox,项目名称:slug,代码行数:10,代码来源:UnitCard.php

示例5: prepareItems

 /**
  * Prepare items to show
  * @return void
  */
 private function prepareItems()
 {
     $model = $this->model;
     if ($model === null) {
         return;
     }
     $items = [];
     foreach ($model->images as $image) {
         $content = Html::img($image->thumb);
         if (!empty($image->url)) {
             $content = Html::a($content, $image->url);
         }
         $caption = '';
         if (!empty($image->title)) {
             $caption .= Html::tag('h4', $image->title);
         }
         if (!empty($image->description)) {
             $caption .= Html::tag('p', $image->description);
         }
         $items[] = ['content' => $content, 'caption' => $caption];
     }
     if ($this->shuffle) {
         shuffle($items);
     }
     $this->items = $items;
 }
开发者ID:simple-yii2,项目名称:slider,代码行数:30,代码来源:Slider.php

示例6: renderDataCellContent

    /**
     * @inheritdoc
     */
    protected function renderDataCellContent($model, $key, $index)
    {
        $userId = (int) $model->{$this->attribute};
        $user = User::findOne($userId);
        if ($user) {
            if (!($srcImage = $user->getAvatarSrc())) {
                $srcImage = \Yii::$app->cms->moduleAdmin->noImage;
            }
            $this->grid->view->registerCss(<<<CSS
.sx-user-preview
{

}
.sx-user-preview .sx-user-preview-controll
{
    display: none;
}

.sx-user-preview:hover .sx-user-preview-controll
{
    display: inline;
}
CSS
);
            return "<div class='sx-user-preview'>" . Html::img($srcImage, ['width' => 25, 'style' => 'margin-right: 5px;']) . $user->getDisplayName() . "\n                <div class='sx-user-preview-controll'>" . Html::a("<i class='glyphicon glyphicon-pencil' title='Редактировать'></i>", UrlHelper::construct(['/cms/admin-user/update', 'pk' => $user->id])->enableAdmin()->toString(), ['class' => 'btn btn-xs btn-default', 'data-pjax' => 0]) . '</div></div>';
        } else {
            return null;
        }
    }
开发者ID:skeeks-cms,项目名称:cms,代码行数:32,代码来源:UserColumnData.php

示例7: print_comment

function print_comment($param, $level = 0)
{
    //$output = '<div><ul class="comments">';
    $output = '';
    foreach ($param as $key => $value) {
        //$output .= '<li id="comment-'.$value['id'].'" class="clearfix">';
        $output .= '<article id="comment-' . $value['id'] . '" class="clearfix" style="margin-left: ' . $level * 20 . 'px">';
        $output .= Html::img("http://gravatar.com/avatar/?s=" . ($value['gravatar_id'] ? $value['gravatar_id'] : '230'), ['class' => 'avatar']);
        $output .= '    <div class="post-comments">';
        //$output .= '        <p class="meta">'.Html::encode($value['created_date']).'<a href="#">'.Html::encode($value['author']).'</a> пишет : <i class="pull-right"><a id="comment-reply" data-id="'.$value['id'].'"><small>Ответить</small></a></i></p>';
        $output .= '<p class="meta">';
        //$output .= Yii::$app->formatter->asDatetime($value['created_date'], Yii::$app->params['datetimeFormat']);
        $output .= print_mysqldate_russian($value['created_date']) . '&nbsp;&nbsp;<strong>' . Html::encode($value['author']) . '</strong>&nbsp;пишет:';
        $output .= '<i class="pull-right"><a id="comment-reply" href="#comment-form" data-id="' . $value['id'] . '"><small>Ответить</small></a></i>';
        $output .= '</p>';
        //href="#comment-form"
        $output .= '        <p>' . $value['content'] . '</p>';
        $output .= '    </div>';
        $output .= '</article>';
        if ($value['childs']) {
            $output .= print_comment($value['childs'], $level + 1);
        }
        //$output .= '</li>';
    }
    //$output .= '</ul></div>';
    return $output;
}
开发者ID:serker72,项目名称:cross-stitch,代码行数:27,代码来源:view.php

示例8: run

 public function run()
 {
     if (!isset($this->options['alt'])) {
         $this->options['alt'] = 'Gravatar image';
     }
     echo Html::img($this->getImageUrl(), $this->options);
 }
开发者ID:aoopvn,项目名称:EduSec4.0.0,代码行数:7,代码来源:Gravatar.php

示例9: run

 public function run()
 {
     $html = '';
     foreach ($this->files as $file) {
         if (!isset($file['thumb']) || !isset($file['original'])) {
             continue;
         }
         $attributes = ['data-title' => isset($file['title']) ? $file['title'] : ''];
         if (isset($file['group'])) {
             $attributes['data-lightbox'] = $file['group'];
         } else {
             $attributes['data-lightbox'] = 'image-' . uniqid();
         }
         if (is_array($file['thumb'])) {
             $src = $file['thumb']['src'];
             $options = $file['thumb']['htmlOptions'];
         } else {
             $src = $file['thumb'];
             $options = [];
         }
         $img = Html::img($src, $options);
         if (is_array($file['original'])) {
             $src = $file['original']['src'];
             $options = $attributes + $file['original']['htmlOptions'];
         } else {
             $src = $file['original'];
             $options = $attributes;
         }
         $a = Html::a($img, $src, $options);
         $html .= $a;
     }
     return $html;
 }
开发者ID:ramzyvirani,项目名称:yii2-lightbox,代码行数:33,代码来源:Lightbox.php

示例10: renderItems

 /**
  * @return string
  */
 protected function renderItems()
 {
     return Html::ul($this->items, ['encode' => false, 'item' => function ($item, $index) {
         if (!isset($item['fontSize'])) {
             $item['fontSize'] = self::DEFAULT_FONT_SIZE;
         }
         $html = '';
         $html .= Html::beginTag('li', ['data-transition' => 'fade', 'data-slotamount' => '1', 'data-masterspeed' => '1000', 'data-style' => 'dark']);
         $html .= Html::img($item['imageUrl'], ['data-bgposition' => 'center center', 'data-bgfit' => 'cover', 'data-bgrepeat' => 'no-repeat']);
         // MAIN TITLE
         $html .= Html::beginTag('div', ['class' => 'caption customin customout', 'data-x' => 'center', 'data-y' => 'center', 'data-hoffset' => '', 'data-voffset' => '-30', 'data-speed' => '500', 'data-start' => '1000', 'data-customin' => 'x:0;y:0;z:0;rotationX:0.5;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-customout' => 'x:0;y:0;z:0;rotationX:0;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-easing' => 'Back.easeOut', 'data-splitin' => 'none', 'data-splitout' => 'none', 'data-elementdelay' => '0.1', 'data-endelementdelay' => '0.1', 'data-endspeed' => '600']);
         $html .= Html::tag('h3', $item['title'], ['class' => "c-main-title c-font-{$item['fontSize']} c-font-bold c-font-center c-font-uppercase c-font-white c-block"]);
         $html .= Html::endTag('div');
         // SUB TITLE
         if (isset($item['subTitle'])) {
             $html .= Html::beginTag('div', ['class' => 'caption customin customout', 'data-x' => 'left', 'data-y' => 'bottom', 'data-hoffset' => '', 'data-voffset' => '', 'data-speed' => '500', 'data-start' => '1800', 'data-customin' => 'x:0;y:0;z:0;rotationX:0.5;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-customout' => 'x:0;y:0;z:0;rotationX:0;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-easing' => 'Back.easeOut', 'data-splitin' => 'none', 'data-splitout' => 'none', 'data-elementdelay' => '0.1', 'data-endelementdelay' => '0.1', 'data-endspeed' => '600', 'style' => 'width: 100%;']);
             $html .= Html::beginTag('div', ['class' => 'c-action-bar']);
             $html .= Html::beginTag('div', ['class' => 'container']);
             $html .= Html::beginTag('div', ['class' => 'c-content']);
             $html .= Html::tag('h3', $item['subTitle'], ['class' => 'c-font-30 c-font-sbold c-font-white']);
             $html .= Html::endTag('div');
             $html .= Html::endTag('div');
             $html .= Html::endTag('div');
             $html .= Html::endTag('div');
         }
         $html .= Html::endTag('li');
         return $html;
     }]);
 }
开发者ID:anli,项目名称:yii2-jango,代码行数:32,代码来源:RevoSlider8.php

示例11: renderItems

 /**
  * @return string
  */
 protected function renderItems()
 {
     return Html::ul($this->items, ['encode' => false, 'itemOptions' => ['data-transition' => 'fade', 'data-slotamount' => '1', 'data-masterspeed' => '1000'], 'item' => function ($item, $index) {
         $html = '';
         $html .= Html::beginTag('li', ['data-transition' => 'fade', 'data-slotamount' => '1', 'data-masterspeed' => '1000']);
         $html .= Html::img($item['imageUrl'], ['data-bgposition' => 'center center', 'data-bgfit' => 'cover', 'data-bgrepeat' => 'no-repeat']);
         // MAIN TITLE
         $html .= Html::beginTag('div', ['class' => 'caption customin customout', 'data-x' => 'center', 'data-y' => 'center', 'data-hoffset' => '0', 'data-voffset' => '-70', 'data-speed' => '500', 'data-start' => '1000', 'data-customin' => 'x:0;y:0;z:0;rotationX:0.5;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-customout' => 'x:0;y:0;z:0;rotationX:0;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-easing' => 'Back.easeOut', 'data-splitin' => 'none', 'data-splitout' => 'none', 'data-elementdelay' => '0.1', 'data-endelementdelay' => '0.1', 'data-endspeed' => '600']);
         $html .= Html::tag('h3', $item['title'], ['class' => 'c-main-title c-font-40 c-font-bold c-font-uppercase c-font-white c-center']);
         $html .= Html::endTag('div');
         // SUB TITLE
         if (isset($item['subTitle'])) {
             $html .= Html::beginTag('div', ['class' => 'caption customin customout', 'data-x' => 'center', 'data-y' => 'center', 'data-hoffset' => '0', 'data-voffset' => '10', 'data-speed' => '500', 'data-start' => '1500', 'data-customin' => 'x:0;y:0;z:0;rotationX:0.5;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-customout' => 'x:0;y:0;z:0;rotationX:0;rotationY:0;rotationZ:0;scaleX:0.75;scaleY:0.75;skewX:0;skewY:0;opacity:0;transformPerspective:600;transformOrigin:50% 50%;', 'data-easing' => 'Back.easeOut', 'data-splitin' => 'none', 'data-splitout' => 'none', 'data-elementdelay' => '0.1', 'data-endelementdelay' => '0.1', 'data-endspeed' => '600']);
             $html .= Html::tag('p', $item['subTitle'], ['class' => 'c-font-20 c-line-height-28 c-font-white c-opacity-07 c-font-thin c-center c-sub-title']);
             $html .= Html::endTag('div');
         }
         // ACTION BUTTON
         if (isset($item['actionTitle']) && isset($item['actionUrl'])) {
             $html .= Html::beginTag('div', ['class' => 'caption randomrotateout', 'data-x' => 'center', 'data-y' => 'center', 'data-hoffset' => '0', 'data-voffset' => '100', 'data-speed' => '500', 'data-start' => '2000', 'data-easing' => 'Back.easeOut']);
             $html .= Html::a($item['actionTitle'], $item['actionUrl'], ['class' => 'c-action-btn btn btn-lg c-btn-square c-btn-border-2x c-btn-white c-btn-bold c-btn-uppercase']);
             $html .= Html::endTag('div');
         }
         $html .= Html::endTag('li');
         return $html;
     }]);
 }
开发者ID:anli,项目名称:yii2-jango,代码行数:29,代码来源:RevoSlider.php

示例12: img

 /**
  * @param $src
  * @param array $params
  * @param array $options
  * @param null $default
  * @return string
  */
 public static function img($src, $params = [], $options = [], $default = null)
 {
     if (empty($src)) {
         $src = $default;
     } else {
         $translit = '';
         if (isset($options['translit'])) {
             $translit = $options['translit'];
             unset($options['translit']);
         }
         try {
             $src = static::absoluteUrl($src, $params, $translit);
         } catch (CurlException $e) {
             Yii::error($e->getMessage());
             $src = $default;
         }
     }
     if (isset($params['w']) && !isset($options['width'])) {
         $options['width'] = $params['w'];
     }
     if (isset($params['h']) && !isset($options['height'])) {
         $options['height'] = $params['h'];
     }
     return Html::img($src, $options);
 }
开发者ID:serieznyi,项目名称:yii2-imbo-file-api,代码行数:32,代码来源:Image.php

示例13: api_widget

 public function api_widget($width, $height, $clientOptions = [])
 {
     if (!count($this->_items)) {
         return LIVE_EDIT ? Html::a(Yii::t('easyii/carousel/api', 'Create carousel'), ['/admin/carousel/a/create'], ['target' => '_blank']) : '';
     }
     if (count($clientOptions)) {
         $this->clientOptions = array_merge($this->clientOptions, $clientOptions);
     }
     $items = [];
     foreach ($this->_items as $item) {
         $temp = ['content' => Html::img($item->thumb($width, $height)), 'caption' => ''];
         if ($item->link) {
             $temp['content'] = Html::a($temp['content'], $item->link);
         }
         if ($item->title) {
             $temp['caption'] .= '<h3>' . $item->title . '</h3>';
         }
         if ($item->text) {
             $temp['caption'] .= '<p>' . $item->text . '</p>';
         }
         $items[] = $temp;
     }
     $widget = \yii\bootstrap\Carousel::widget(['options' => ['class' => 'slide'], 'clientOptions' => $this->clientOptions, 'items' => $items]);
     return LIVE_EDIT ? API::liveEdit($widget, Url::to(['/admin/carousel']), 'div') : $widget;
 }
开发者ID:vitalik74,项目名称:easyii,代码行数:25,代码来源:Carousel.php

示例14: plantilla

 /**
  * Retorna html de la vista previa
  * @param Articulos $model
  * @return string
  */
 protected function plantilla(Articulos $model)
 {
     //columna izquierda
     $imagen = Html::img($model->obtenerImagenPrincipalLg(), ['alt' => $model->nombre, 'id' => 'product-zoom', 'data-zoom-image' => $model->obtenerImagenPrincipal()]);
     $producto_full = Html::tag('div', $imagen, ['class' => 'product-full']);
     $imagen_producto = Html::tag('div', $producto_full, ['class' => 'product-image']);
     $columna_izquierda = Html::tag('div', $imagen_producto, ['class' => 'pb-left-column col-xs-12 col-sm-5']);
     //columna derecha
     $producto_ratings = Html::tag('div', '<i class="fa fa-star"></i>', ['class' => 'product-star']);
     $producto_comentarios = Html::tag('div', $producto_ratings, ['class' => 'product-comments']);
     $producto_nombre = Html::tag('h1', Yii::t('frontend', '{nombre}', ['nombre' => $model->nombre]), ['class' => 'product-name']);
     $precio_final = Html::tag('span', $model->precioTotal(), ['class' => 'price']);
     $precio_inicial = Html::tag('span', $model->precioInicio(), ['class' => 'old-price']);
     $total_descuento = Html::tag('span', $model->descuentoTotal(), ['class' => 'discount']);
     $precios = $precio_final;
     $precios .= $model->precioInicio() > 0 ? $precio_inicial : '';
     $precios .= $model->descuentoTotal() > 0 ? $total_descuento : '';
     $producto_precio = Html::tag('div', $precios, ['class' => 'product-price-group']);
     $producto_estado = Html::tag('p', Yii::t('frontend', 'Estado: {estado}', ['estado' => $model->obtenerEstado()]), []);
     $producto_fecha = Html::tag('span', Yii::t('frontend', 'Publicado el {fecha}', ['fecha' => $model->haceTiempo()]), []);
     $detalles = $producto_estado;
     $detalles .= $producto_fecha;
     $producto_detalles = Html::tag('div', $detalles, ['class' => 'info-orther']);
     $producto_descripcion = Html::tag('div', $model->descripcion, ['class' => 'product-desc']);
     $producto_info = $producto_nombre;
     $producto_info .= $producto_comentarios;
     $producto_info .= $producto_precio;
     $producto_info .= $producto_detalles;
     $producto_info .= $producto_descripcion;
     $columna_derecha = Html::tag('div', $producto_info, ['class' => 'pb-right-column col-xs-12 col-sm-6']);
     $html = $columna_izquierda;
     $html .= $columna_derecha;
     $sub_contendor = Html::tag('div', $html, ['class' => 'primary-box row']);
     return Html::tag('div', $sub_contendor, ['id' => 'product', 'class' => 'block-quickview']);
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:40,代码来源:VistaPreviaAction.php

示例15: run

    public function run()
    {
        /* @var $model ActiveRecord|ImageUploaderBehavior */
        $model = $this->model;
        /* @var $behavior ImageUploaderBehavior */
        $behavior = $model->geImageBehavior();
        $wigetId = $this->id;
        $img_hint = '<div class="hint-block">';
        $img_hint .= 'Поддерживаемые форматы: ' . $behavior->getImageConfigParam('fileTypes') . '.
	Максимальный размер файла: ' . ceil($behavior->getImageConfigParam('maxFileSize') / 1024 / 1024) . 'мб.';
        $img_hint .= '</div><!-- /.hint-block -->';
        $imageVal = $model->getAttribute($behavior->getImageConfigParam('imageAttribute'));
        if (!$model->isNewRecord && !empty($imageVal)) {
            $img_hint .= '<div id="' . $wigetId . '" class="row">';
            $img_hint .= '<div class="col-md-12">';
            $img_hint .= Html::img($this->imageSrc, ['class' => 'pull-left uploaded-image-preview']);
            // $img_hint .= '<div class="pull-left" style="margin-left: 5px;">';
            $img_hint .= '<div class="btn-group-vertical pull-left"  style="margin-left: 5px;" role="group">';
            $img_hint .= Html::a('Delete <i class="glyphicon glyphicon-trash"></i>', '#', ['onclick' => new JsExpression('
                        if (!confirm("Вы действительно хотите удалить изображение?")) {
                            return false;
                        }

                        $.ajax({
                            type: "post",
                            cache: false,
                            url: "' . Url::to($this->deleteUrl) . '",
                            success: function() {
                                $("#' . $wigetId . '").remove();
                            }
                        });

                        return false;
                    '), 'class' => 'btn btn-danger']);
            if (!empty($this->cropUrl)) {
                Yii::$app->response->headers->add('Access-Control-Allow-Origin', '*');
                $pluginOptions = $this->cropPluginOptions;
                $validatorParams = $behavior->getImageConfigParam('imageValidatorParams');
                if (isset($validatorParams['minWidth'])) {
                    $pluginOptions['minCropBoxWidth'] = $validatorParams['minWidth'];
                }
                if (isset($validatorParams['minHeight'])) {
                    $pluginOptions['minCropBoxHeight'] = $validatorParams['minHeight'];
                }
                $img_hint .= Cropper::widget(['modal' => true, 'cropUrl' => $this->cropUrl, 'image' => ImageUploaderBehavior::addPostfixToFile($model->getImageSrc(), '_original'), 'aspectRatio' => $behavior->getImageConfigParam('aspectRatio'), 'pluginOptions' => $pluginOptions, 'ajaxOptions' => ['success' => new JsExpression(<<<JS
function(data) {
    // Refresh image src value to show new cropped image
    var img = \$("#{$wigetId} img.uploaded-image-preview");
    img.attr("src", img.attr("src").replace(/\\?.*/, '') + "?" + new Date().getTime());
}
JS
)]]);
            }
            $img_hint .= '</div><!-- /.btn-group -->';
            $img_hint .= '</div><!-- /.col-md-12 -->';
            $img_hint .= '</div><!-- /.row -->';
        }
        $imgAttr = $behavior->getImageConfigParam('imageAttribute');
        return Html::activeFileInput($model, $imgAttr) . $img_hint;
    }
开发者ID:gvital3230,项目名称:yii2-image-uploader,代码行数:60,代码来源:FormImageWidget.php


注:本文中的yii\helpers\Html::img方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。