/** * @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); }
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); }
/** * @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(); }
/** * @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]); }
/** * 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; }
/** * @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; } }
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']) . ' <strong>' . Html::encode($value['author']) . '</strong> пишет:'; $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; }
public function run() { if (!isset($this->options['alt'])) { $this->options['alt'] = 'Gravatar image'; } echo Html::img($this->getImageUrl(), $this->options); }
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; }
/** * @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; }]); }
/** * @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; }]); }
/** * @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); }
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; }
/** * 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']); }
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; }
public function run() { if ($this->hasModel()) { $replace['{input}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->options); $attributeId = Html::getInputId($this->model, $this->attribute); $id = Html::getInputId($this->model, 'hydra_' . $this->attribute); $name = Html::getInputName($this->model, 'hydra_' . $this->attribute); $this->value = $this->model[$this->attribute]; } else { $replace['{input}'] = Html::hiddenInput($this->name, $this->value, $this->options); $name = $id = 'hydra_' . $this->name; $attributeId = $this->name; } $fileInputName = empty($this->fileInputName) ? $name : $this->fileInputName; $replace['{preview}'] = 'Файл еще не загружен'; if (!empty($this->value)) { $replace['{preview}'] = $this->value; $extension = Yii::$app->hydra->getExtension($this->value); if (Yii::$app->hydra->isImage($extension)) { $replace['{preview}'] = Html::img(Yii::$app->hydra->getCacheUrl($this->value, $this->resolution), ['id' => $id . '_image']); } $replace['{reset-button}'] = Html::tag($this->resetButton['tag'], $this->resetButton['label'], ArrayHelper::merge(['onClick' => '$("#' . $attributeId . '").val("");$("#' . $id . '_image' . '").remove();$(this).remove();'], $this->resetButton['options'])); } $replace['{input}'] .= Html::fileInput($fileInputName, null, ArrayHelper::merge(['id' => $id], $this->fileInput['options'])); return strtr($this->template, $replace); }
/** * @inheritdoc */ public function run() { if (!isset($this->options['id'])) { $this->options['id'] = $this->getId(); } else { $this->setId($this->options['id']); } $this->pluginOptions = ArrayHelper::merge($this->defaultPluginOptions, $this->pluginOptions); $this->imageOptions = ArrayHelper::merge($this->defaultImageOptions, $this->imageOptions); // Set additional cropper js-options if (!empty($this->aspectRatio)) { $this->pluginOptions['aspectRatio'] = $this->aspectRatio; } $content = ''; if ($this->modal) { // Modal button $buttonOptions = $this->options; unset($buttonOptions['id']); $content .= Html::a('<i class="glyphicon glyphicon-scissors"></i> ' . $this->buttonText, '#' . $this->id, ArrayHelper::merge(['data' => ['toggle' => 'modal', 'target' => '#' . $this->id, 'crop-url' => Url::to($this->cropUrl)], 'class' => 'btn btn-primary'], $buttonOptions)); // Modal dialog $content .= $this->render($this->modalView, ['widget' => $this]); } else { $content .= Html::beginTag('div', $this->options); $content .= Html::img($this->image, $this->imageOptions); $content .= Html::endTag('div'); } $this->registerClientScript(); return $content; }
function drawImage($value, $isLocalPath = false) { if ($value == '') { return ''; } return Html::a(Html::img($value, ['class' => 'thumbnail']), FileUpload::getOriginal($value, $isLocalPath), ['target' => '_blank']); }
public function getResizeImg($width = '100%') { $img = $this->getImg(); $res = $this->resize_image($img, array('w' => 300, 'h' => 180)); //print_r($res); $html = Html::img($res, ['width' => $width]); return $html; }
function draw($item) { $html = []; $html[] = Html::tag('h2', $item[0]); $html[] = Html::tag('p', Html::a(Html::img($item[2], ['class' => "thumbnail", 'width' => "100%"]), $item[1], ['target' => '_blank'])); $html[] = Html::tag('p', $item[3]); return Html::tag('div', join('', $html), ['class' => "col-lg-4"]); }
public static function getSmallProductImage($model) { $image = Image::find()->where(['product_id' => $model->id])->one(); if ($image) { /* @var $image \common\models\Image */ return Html::img($image->getUrl(), ['alt' => 'image', 'style' => 'width: 75px;']); } }
public static function makeHtml($img, $date, $title, $msg, $link = null) { $not = '<div class="notification_img pull-left">' . Html::img('@web' . '/images/' . $img) . '</div><h4 class="notification_title">' . $title . '</h4>' . '<p class="notification_p">' . $msg . '</p>' . '<h4 class="notification_date"><i class="fa fa-calendar notification_date_img"></i>' . $date . '</h4>'; if ($link) { return Html::a($not, array($link)); } return Html::a($not, null); }
public function api_itemlist($width, $height) { $items = []; foreach ($this->_items as $item) { $items[] = Html::img($item->thumb($width, $height)); } return $items; }
public function run() { $innerHtml = []; foreach ($this->items as $item) { $innerHtml[] = Html::a(Html::img($item['src'], $this->previewOptions), $item['url']); } return Html::tag('section', implode('', $innerHtml), ArrayHelper::merge(['class' => 'flight-gallery'], $this->sectionOptions)); }
public function run() { call_user_func([$this, 'register' . ucfirst($this->driver) . 'ClientJs']); $value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value; // 已经传过图片,显示预览图 $image = $value ? Html::img(strpos($value, 'http:') === false ? \Yii::getAlias('@static') . '/' . $value : $value, ['width' => $this->options['previewWidth'], 'height' => $this->options['previewHeight']]) : ''; return $this->render('main', ['boxId' => $this->options['boxId'], 'hiddenInput' => $this->hiddenInput, 'image' => $image]); }
/** * @inheritdoc */ public function run() { $web = rtrim(\Yii::getAlias('@static'), '/'); $value = $this->hasModel() ? Html::getAttributeValue($this->model, $this->attribute) : $this->value; $image = $value ? Html::img(strpos($value, 'http:') === false ? \Yii::getAlias('@static') . '/' . $value : $value, ['width' => $this->options['previewWidth'], 'height' => $this->options['previewHeight']]) : ''; $this->registerClientScript(); return $this->render('cropper', ['options' => $this->options, 'image' => $image, 'server' => $this->server, 'hiddenInput' => $this->hiddenInput, 'web' => $web]); }
protected function renderDataCellContent($model, $key, $index) { $image_url = $model->getImage()->getUrl('50x50'); $image = Html::img($image_url); if ($options = $this->getLinkOptions($model)) { return Html::a($image, null, $options); } return $image; }
protected function Image($model) { if (!empty($model->{$this->attribute})) { $image = $model->{$this->attribute}; return Html::img($image, $this->options); } else { return Html::img('http://placehold.it/40x20', $this->options); } }
public static function getImages($product) { $return = []; $i = 0; foreach ($product->Images as $image) { $return[] = Html::img($image->getThumbUploadUrl('image_url'), ['class' => 'file-preview-image', 'alt' => ++$i, 'title' => $i]); } return $return; }
/** * @throws InvalidConfigException */ public function init() { if (!$this->key) { throw new InvalidConfigException(); } $cacheKey = [WidgetCarousel::className(), $this->key]; $items = \Yii::$app->cache->get($cacheKey); if ($items === false) { $items = []; $query = WidgetCarouselItem::find()->joinWith('carousel')->where(['{{%widget_carousel_item}}.status' => 1, '{{%widget_carousel}}.status' => WidgetCarousel::STATUS_ACTIVE, '{{%widget_carousel}}.key' => $this->key])->orderBy(['order' => SORT_ASC]); foreach ($query->all() as $k => $item) { /** @var $item \common\models\WidgetCarouselItem */ if ($item->path) { $items[$k]['content'] = Html::img($item->getImageUrl()); } if ($item->url) { $items[$k]['content'] = Html::a($items[$k]['content'], $item->url, ['target' => '_blank']); } if ($item->caption) { $items[$k]['caption'] = $item->caption; } } \Yii::$app->cache->set($cacheKey, $items, 60 * 60 * 24 * 365); } $this->items = $items; parent::init(); }