thumb() public static method

* Create a thumbnail of an image and returns relative path in webroot * the options array is an associative array which can take the values * quality (jpg quality) and method (the method for resizing) * * @param int $width * @param int $height * @param string $img * @param array $options * @return string $path
public static thumb ( integer $width, integer $height, string $img, array $options = null ) : string
$width integer
$height integer
$img string
$options array
return string
Exemplo n.º 1
0
 public static function getChildsId($id)
 {
     $data = array();
     $ids = array();
     if (!is_array($id)) {
         $id = array($id);
     }
Exemplo n.º 2
0
 public function getThumb($size = null, $crop = true)
 {
     if (is_string($size)) {
         $size = ['width' => 64, 'height' => 64];
     }
     $dir = pathinfo($this->getPk(), PATHINFO_DIRNAME);
     $name = pathinfo($this->getPk(), PATHINFO_BASENAME);
     return ImageHelper::thumb($dir, $name, $size, $crop)->getSrc();
 }
Exemplo n.º 3
0
 public function run()
 {
     $val = $this->model->{$this->attribute};
     if (!$this->model->isNewRecord && $val) {
         $id = $this->id . get_class($this);
         $files_data = $this->model->uploadFiles();
         $attribute_data = $files_data[$this->attribute];
         $directory = trim($attribute_data['dir'], '/');
         $preview = ImageHelper::thumb($directory, $val, array('width' => null, 'height' => 128));
         $preview .= CHtml::ajaxLink('X', array('/main/helpAdmin/saveAttribute'), array('type' => 'post', 'data' => array('model' => get_class($this->model), 'id' => $this->model->primaryKey, 'attribute' => $this->attribute, 'value' => '', 'unlink_file' => $directory . '/' . $val), 'success' => 'js:function() {$("#' . $id . '").remove();}'), array('class' => 'btn btn-danger delete-img'));
         echo CHtml::tag('div', array('id' => $id), $preview);
     }
     echo CHtml::activeFileField($this->model, $this->attribute, $this->htmlOptions);
 }
Exemplo n.º 4
0
 public function getThumb()
 {
     $img_url = '/../../upload/category/' . $this->pic;
     $trueimage = Yii::app()->request->hostInfo . Yii::app()->baseUrl . $img_url;
     if (F::isfile($trueimage)) {
         $img_thumb = Yii::app()->request->baseUrl . ImageHelper::thumb(750, 368, $img_url, array('method' => 'resize'));
         $img_thumb_now = CHtml::image($img_thumb, $this->name);
         return CHtml::link($img_thumb_now, $this->url, array('title' => $this->name));
     } else {
         return '没有图片';
     }
 }
Exemplo n.º 5
0
                <div class="pd_slider_img">
                    <div id="xxx">
                        <script>
                            var box = new PPTBox();
                            box.width = 180; //宽度
                            box.height = 178;//高度
                            box.autoplayer = 5;//自动播放间隔时间
                            //box.add({"url":"图片地址","title":"悬浮标题","href":"链接地址"})
                            <?php 
$recommendItems = Item::model()->findAll(array('condition' => 'is_best=?', 'params' => array('1'), 'limit' => 3));
$num = count(recommendItems);
if ($num > 0) {
    foreach ($recommendItems as $value) {
        if ($value->getMainPic()) {
            $imageHelper = new ImageHelper();
            $picUrl = $imageHelper->thumb('180', '178', $value->getMainPic());
        } else {
            $picUrl = $value->getHolderJs('180', '178');
        }
        ?>
                                         box.add({"url": "<?php 
        echo $picUrl;
        ?>
", "href": "<?php 
        echo $this->createUrl('item/view', array('id' => $value->item_id));
        ?>
", "title": "<?php 
        echo $value->title;
        ?>
"});
                                    <?php 
Exemplo n.º 6
0
Arquivo: Ad.php Projeto: yinhe/yincart
 /**
  * 得到图片图像
  * @return type
  */
 public function getImage()
 {
     $img = $this->getImagePath();
     if (file_exists(dirname(F::basePath()) . $img)) {
         $img_thumb = F::baseUrl() . ImageHelper::thumb(990, 486, $img, array('method' => 'resize'));
         $img_thumb_now = CHtml::image($img_thumb, $this->title);
         return CHtml::link($img_thumb_now, $this->url, array('title' => $this->title));
     } else {
         return CHtml::link(CHtml::image($this->getHolderJs('990', '486')), $this->url, array('title' => $this->title));
     }
 }
Exemplo n.º 7
0
 /**
  * get item main picture
  * @param string $width
  * @param string $height
  * @return mixed
  * @author milkyway(yhxxlm@gmail.com)
  */
 public function getMainPic($width = '310', $height = '310')
 {
     $img = $this->getMainPicPath();
     if (file_exists($this->getMainPicOriginalPath())) {
         $img_thumb = F::baseUrl() . ImageHelper::thumb($width, $height, $img, array('method' => 'resize'));
         $img_thumb = str_replace('/../../upload', 'http://' . F::sg('site', 'imageDomain'), $img_thumb);
         $img_thumb_now = CHtml::image($img_thumb, $this->title);
         return CHtml::link($img_thumb_now, $this->getUrl(), array('title' => $this->title));
     } else {
         return CHtml::link(CHtml::image($this->getHolderJs($width, $height)), $this->getUrl(), array('title' => $this->title));
     }
 }
Exemplo n.º 8
0
echo Yii::app()->baseUrl . '/';
?>
">首页>></a>
            <?php 
foreach ($this->breadcrumbs as $breadcrumb) {
    echo '<a href="' . $breadcrumb['url'] . '">' . $breadcrumb['name'] . '</a>';
}
?>
        </div>
        <div class="deal_pic">
            <div>
                <ul id="idNum" class="hdnum">
                    <?php 
foreach ($item->itemImgs as $itemImg) {
    if (!empty($itemImg->pic)) {
        $picUrl = $imageHelper->thumb('70', '70', $itemImg->pic);
        $picUrl = yii::app()->baseUrl . $picUrl;
    } else {
        $picUrl = $item->getHolderJs('70', '70');
    }
    echo '<li><img src="' . $picUrl . '" width="70" height="70"></li>';
}
?>
                </ul>
            </div>
            <div style="width: 450px; height: 450px; overflow: hidden; position: relative;" id="idTransformView" class="idtransformview">
                <ul id="idSlider" class="slider">
                    <?php 
foreach ($item->itemImgs as $itemImg) {
    if ($itemImg->pic) {
        $picUrl = $imageHelper->thumb('450', '450', $itemImg->pic);
Exemplo n.º 9
0
                    <th class="col-xs-1">数量</th>
                    <th class="col-xs-1">小计</th>
                </tr>
                <?php 
$cart = Yii::app()->cart;
if (isset($item)) {
    $item->getId();
    if ($keys == null) {
        echo CHtml::hiddenField('sku_id', $item->sku->sku_id);
        echo CHtml::hiddenField('item_id', $item->sku->item_id);
        echo CHtml::hiddenField('quantity', $item->getQuantity());
    }
    ?>
                    <tr><?php 
    if ($item->getMainPic()) {
        $picUrl = $imageHelper->thumb('70', '70', $item->getMainPic());
        ?>
                        <td><?php 
        echo CHtml::image($picUrl, $item->title, array('width' => '80px', 'height' => '80px'));
    } else {
        echo Yii::t('leather', '该商品没有上传图片');
    }
    ?>
</td>
                        <td><?php 
    echo $item->title;
    ?>
</td>
                        <td><?php 
    echo empty($item->sku) ? '' : implode(';', json_decode($item->sku->props_name, true));
    ?>
Exemplo n.º 10
0
         $img_thumb = Yii::app()->request->baseUrl . ImageHelper::thumb(150, 150, $img, array('method' => 'resize'));
         $img_thumb_now = CHtml::image($img_thumb, $this->item_name);
         return CHtml::link($img_thumb_now, array('/item/view', 'id' => $this->id));
     } else {
         return 'No Pic';
     }
 }
 public function getSmallThumb()
 {
     $img = '/upload/item/' . $this->item_image;
     $trueimage = 'http://wcydboss.com' . $img;
     if (F::isfile($trueimage)) {
Exemplo n.º 11
0
 public function getRecommendThumb()
 {
     $img = '/upload/item/' . $this->pic_url;
     $trueimage = Yii::app()->request->hostInfo . $img;
     if (F::isfile($trueimage)) {
         $img_thumb = Yii::app()->request->baseUrl . ImageHelper::thumb(80, 80, $img, array('method' => 'resize'));
         $img_thumb_now = CHtml::image($img_thumb, $this->title);
         return CHtml::link($img_thumb_now, array('/item/view', 'id' => $this->item_id), array('title' => $this->title));
     } else {
         return '没有图片';
     }
 }
Exemplo n.º 12
0
">更多新品>></a></div>
                    <div class="product_ca">
                        <div class="product_list_ca">
                            <?php 
        foreach ($items as $newItem) {
            $itemUrl = Yii::app()->createUrl('item/view', array('id' => $newItem->item_id));
            ?>
                                <div class="product_e">
                                    <div class="product_img"><a href="<?php 
            echo $itemUrl;
            ?>
">
                                            <?php 
            if ($newItem->getMainPic()) {
                $image = new ImageHelper();
                $picUrl = $image->thumb('220', '220', $newItem->getMainPic());
                $picUrl = Yii::app()->baseUrl . $picUrl;
            } else {
                $picUrl = $newItem->getHolderJs('220', '220');
            }
            ?>
                                            <img alt="<?php 
            echo $newItem->title;
            ?>
" src="<?php 
            echo $picUrl;
            ?>
"
                                                 width="220" height="220"></a>
                                    </div>
                                    <div class="product_name">
Exemplo n.º 13
0
<br/>
<div class="row">
    <div class="span2">
        <?
        $avatar_size = array('width' => 170, 'height' => 100);
        $avatar = ImageHelper::thumb(User::PHOTO_PATH, $model->photo, $avatar_size, true);
        echo $avatar->isRealImage() ? $avatar : ImageHelper::placeholder($avatar_size);
        ?>
    </div>
    <div class="span3">
        <table class="table table-bordered table-striped">
            <tbody>
            <? if ($model->name) { ?>
                <tr>
                    <td>Имя</td>
                    <td><?php 
echo $model->name;
?>
</td>
                </tr>
            <? } ?>
            <? if ($model->email) { ?>
                <tr>
                    <td>Email</td>
                    <td><?php 
echo $model->email;
?>
</td>
                </tr>
            <? } ?>
            </tbody>
Exemplo n.º 14
0
 /**
  * 得到最近商品缩略图
  * @return type
  */
 public function getRecentThumb()
 {
     $img = $this->getMainPicPath();
     if (file_exists(dirname(F::basePath()) . $img)) {
         $img_thumb = F::baseUrl() . ImageHelper::thumb(210, 210, $img, array('method' => 'resize'));
         $img_thumb_now = CHtml::image($img_thumb, $this->title);
         return CHtml::link($img_thumb_now, array('/item/view', 'id' => $this->item_id), array('title' => $this->title));
     } else {
         return CHtml::link(CHtml::image($this->getHolderJs('210', '210')), $this->getUrl(), array('title' => $this->title));
     }
 }